diff --git a/.copier-answers.yml b/.copier-answers.yml new file mode 100644 index 0000000..43648d6 --- /dev/null +++ b/.copier-answers.yml @@ -0,0 +1,18 @@ +_commit: 0.8.0 +_src_path: gh:georgedouzas/copier-pdm-nox.git +author_email: gdouzas@icloud.com +author_fullname: Georgios Douzas +author_username: georgedouzas +copyright_date: '2019' +copyright_holder: Georgios Douzas +copyright_holder_email: gdouzas@icloud.com +copyright_license: MIT License +project_description: Implementation of the Geometric SMOTE algorithm, a geometrically + enhanced drop-in replacement for SMOTE. It is compatible with scikit-learn and + imbalanced-learn. +python_package_distribution_name: geometric-smote +python_package_import_name: gsmote +python_versions: '>=3.9, <3.12' +repository_name: geometric-smote +repository_namespace: georgedouzas + diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index 07cc74b..0000000 --- a/.coveragerc +++ /dev/null @@ -1,21 +0,0 @@ -# Configuration for coverage.py - -[run] -branch = True -source = gsmote -include = */gsmote/* -omit = - */setup.py - -[report] -exclude_lines = - pragma: no cover - def __repr__ - if self.debug: - if settings.DEBUG - raise AssertionError - raise NotImplementedError - if 0: - if __name__ == .__main__.: - if self.verbose: -show_missing = True \ No newline at end of file diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..5cc17f1 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +github: +- georgedouzas diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..b47675e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,63 @@ +name: Bug report +description: Create a report to help us reproduce and correct the bug. +labels: ['fix'] + +body: +- type: markdown + attributes: + value: > + **Before submitting a bug, please make sure the issue hasn't been already addressed by searching + through [the past issues](https://github.com/georgedouzas/geometric-smote/issues).** +- type: textarea + attributes: + label: Describe the bug + description: > + A clear and concise description of what the bug is. + validations: + required: true +- type: textarea + attributes: + label: Steps or code to reproduce the bug + description: | + Please add a minimal code example that can reproduce the error when running it. + If the code is too long, feel free to put it in a public gist and link it in the issue. + placeholder: | + ``` + Sample code to reproduce the problem + ``` + validations: + required: true +- type: textarea + attributes: + label: Expected Results + description: > + Please paste or describe the expected results. + placeholder: > + Example: No error is thrown. + validations: + required: true +- type: textarea + attributes: + label: Actual Results + description: | + Please paste or describe the results you observe instead of the expected results. If you observe an error, please paste + the error message including the **full traceback** of the exception. + placeholder: > + Please paste or specifically describe the actual output or traceback. + validations: + required: true +- type: textarea + attributes: + label: Environment + description: | + Please provide the following information. + placeholder: > + `geometric-smote` version + Python version + OS + validations: + required: true +- type: markdown + attributes: + value: > + Thanks for contributing! diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..b2a0071 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,11 @@ +blank_issues_enabled: true +contact_links: + - name: Discussions + url: https://github.com/georgedouzas/geometric-smote/discussions + about: Ask questions and discuss with other community members + - name: Gitter + url: https://gitter.im/geometric-smote/community + about: Users and developers can sometimes be found on the gitter channel + - name: Blank issue + url: https://github.com/georgedouzas/geometric-smote/issues/new + about: Please note that Github Discussions should be used in most cases instead diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000..bf43161 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,21 @@ +name: Feature request +description: Suggest a new algorithm, enhancement to an existing algorithm, etc. +labels: ['feat'] + +body: +- type: textarea + attributes: + label: Describe the new feature you propose to be implemented + validations: + required: true +- type: textarea + attributes: + label: Describe your proposed solution + validations: + required: true +- type: textarea + attributes: + label: Describe alternatives you have considered, if relevant +- type: textarea + attributes: + label: Additional context diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..f6c15e7 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,39 @@ +# Pull Request Guide + +## Checklist + +Please check the following: + +- [ ] You have checked the [Pull Request guidelines](https://github.com/georgedouzas/geometric-smote/blob/master/.github/CONTRIBUTING.md). +- [ ] Tests for bug fixes or new features have been added. +- [ ] Docs have been added or updated. + +## Type + +What kind of change does this Pull Request introduce? + +- [ ] feat: New feature implementation. +- [ ] fix: Bug fix. +- [ ] docs: Documentation changes. +- [ ] style: Code style or format changes. +- [ ] refactor: Changes that are not features or bug fixes. +- [ ] tests: Test additions or corrections. +- [ ] chore: Maintenance code changes. +- [ ] other + +## Current behaviour + +Describe the current behaviour or provide a link to an issue. + +## What is the new behavior? + +Describe the new behaviour. + +## Does this Pull Request introduce a breaking change? + +- [ ] Yes +- [ ] No + +## Other information + +Provide any other information. diff --git a/.github/workflows/ci-docs.yml b/.github/workflows/ci-docs.yml new file mode 100644 index 0000000..106f4ae --- /dev/null +++ b/.github/workflows/ci-docs.yml @@ -0,0 +1,111 @@ +name: CI and documentation + +on: + push: + branches-ignore: + - main + workflow_dispatch: + +jobs: + + checks: + + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Python versions + uses: actions/setup-python@v4 + with: + python-version: | + 3.9 + 3.10 + 3.11 + + + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 + with: + cache: true + cache-dependency-path: pyproject.toml + + - name: Install dependencies + run: pdm install --no-default -dG maintenance -dG checks + + - name: Check code quality + run: pdm checks quality + + - name: Check type annotations + run: pdm checks types + + - name: Check vulnerabilities in dependencies + run: pdm checks dependencies + + tests: + + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Python versions + uses: actions/setup-python@v4 + with: + python-version: | + 3.9 + 3.10 + 3.11 + + + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 + with: + cache: true + cache-dependency-path: pyproject.toml + + - name: Install dependencies + run: pdm install -dG maintenance -dG tests + + - name: Run the test suite + run: pdm tests + + doc: + + runs-on: ubuntu-latest + + strategy: + matrix: + python-version: ['3.9', '3.10', '3.11'] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 + with: + cache: true + cache-dependency-path: pyproject.toml + + - name: Install dependencies + run: pdm install -dG maintenance -dG docs + + - name: Build documentation with Python ${{ matrix.python-version }} + run: pdm docs build diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27237cb..c208288 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,70 +1,84 @@ -name: Build +name: CI on: push: - branches: [ master ] - pull_request: - branches: [ master ] - - workflow_dispatch: + branches: + - main jobs: - linting: - name: Linting - runs-on: ubuntu-latest + + checks: + + strategy: + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + + runs-on: ${{ matrix.os }} + steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.9 - architecture: x64 - - - name: Install linters - run: | - pip install pytest black - - name: Run black - run: | - black -S --check --diff gsmote examples/*.py - - build: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Python versions + uses: actions/setup-python@v4 + with: + python-version: | + 3.9 + 3.10 + 3.11 + + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 + with: + cache: true + cache-dependency-path: pyproject.toml + + - name: Install dependencies + run: pdm install --no-default -dG maintenance -dG checks + + - name: Check code quality + run: pdm checks quality + + - name: Check type annotations + run: pdm checks types + + - name: Check vulnerabilities in dependencies + run: pdm checks dependencies + + tests: + strategy: - fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - python: [3.8, 3.9, "3.10"] - name: ${{ matrix.os }} Python ${{ matrix.python }} + os: + - ubuntu-latest + - macos-latest + - windows-latest + runs-on: ${{ matrix.os }} + steps: - - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python }} - architecture: x64 - - - name: Install - run: | - pip install . - pip install -r requirements.test.txt - - - name: Test library - run: | - make test-coverage - coverage xml - - - name: Test Docs - run: | - pip install sphinx - make test-doc - - - name: Upload coverage to codecov - uses: codecov/codecov-action@v2 - with: - files: ./coverage.xml - fail_ci_if_error: false - verbose: true + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Python versions + uses: actions/setup-python@v4 + with: + python-version: | + 3.9 + 3.10 + 3.11 + + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 + with: + cache: true + cache-dependency-path: pyproject.toml + + - name: Install dependencies + run: pdm install -dG maintenance -dG tests + - name: Run the test suite + run: pdm tests diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml new file mode 100644 index 0000000..3f16f63 --- /dev/null +++ b/.github/workflows/doc.yml @@ -0,0 +1,53 @@ +name: Documentation + +on: + push: + branches: + - main + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: 'pages' + cancel-in-progress: true + +jobs: + + doc: + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Pages + uses: actions/configure-pages@v3 + + - name: Set up PDM + uses: pdm-project/setup-pdm@v3 + with: + cache: true + cache-dependency-path: pyproject.toml + + - name: Install dependencies + run: pdm install -dG maintenance -dG docs + + - name: Build documentation + run: pdm docs build + + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + with: + path: 'site' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 diff --git a/.gitignore b/.gitignore index f78eb08..6285262 100644 --- a/.gitignore +++ b/.gitignore @@ -1,63 +1,22 @@ -# Editors -.vscode - -# Virtual environment -.*venv - -# Byte-compiled / optimized / DLL files +.idea/ __pycache__/ *.py[cod] -*$py.class - -# C extensions -*.so - -# scikit-learn specific -doc/_build/ -doc/auto_examples/ -doc/modules/generated/ -doc/datasets/generated/ - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ *.egg-info/ -.installed.cfg -*.egg - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports +build/ htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*,cover -.hypothesis/ +.coverage* +pip-wheel-metadata/ .pytest_cache/ - -# Sphinx documentation -doc/_build/ -doc/generated/ - -# PyBuilder -target/ - -# Various -.DS_Store \ No newline at end of file +.mypy_cache/ +site/ +docs/generated/ +pdm.lock +pdm.toml +.pdm-python +__pypackages__/ +.venv/ +.nox +.ruff_cache +.vscode +.DS_Store diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..e004695 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,33 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.1 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-toml + - id: check-added-large-files +- repo: https://github.com/psf/black + rev: 23.10 + hooks: + - id: black + language_version: python3 +- repo: https://github.com/pre-commit/mirrors-mypy + rev: v1.1.1 + hooks: + - id: mypy + exclude: ^(docs/examples/|docs/generated/|tests/fixtures) +- repo: https://github.com/compilerla/conventional-pre-commit + rev: v2.1.1 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] + args: [feat, fix, docs, style, refactor, tests, chore] +- repo: local + hooks: + - id: pytest + name: Check pytest unit tests pass + entry: pdm tests + pass_filenames: false + language: system + types: [python] diff --git a/.readthedocs.yml b/.readthedocs.yml deleted file mode 100644 index 7ba88b7..0000000 --- a/.readthedocs.yml +++ /dev/null @@ -1,11 +0,0 @@ -build: - image: latest -formats: - - none -requirements_file: requirements.txt -python: - version: 3.6 - pip_install: true - extra_requirements: - - tests - - docs \ No newline at end of file diff --git a/gsmote/tests/__init__.py b/CHANGELOG.md similarity index 100% rename from gsmote/tests/__init__.py rename to CHANGELOG.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..cffb49e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,133 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +gdouzas@icloud.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..75b4387 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,111 @@ +# Contributing + +Contributions are welcome, and they are greatly appreciated. + +## Tasks + +This project uses [nox](https://nox.thea.codes/en/stable/) to run development tasks. Please check the `noxfile.py` at the root of +the project for more details. You can run any of the following commands and subcommands that corresponds to a particular task: + +### Documentation + +- `pdm docs serve` or `pdm docs`: Serve the documentation. +- `pdm docs build`: Build locally the documentation. + +### Formatting + +- `pdm formatting all` or `pdm formatting`: Format both the code and docstrings. + - `pdm formatting code`: Format only the code. + - `pdm formatting docstrings`: Format only the docstrings. + +### Checks + +- `pdm checks all` or `pdm checks`: Run all checks. + - `pdm checks quality`: Check only code quality. + - `pdm checks types`: Check only type annotations. + - `pdm checks dependencies`: Check only for vulnerabilities in dependencies. + +### Tests + +- `pdm tests`: Run the tests. + +### Changelog + +- `pdm changelog`: Build the changelog. + +### Release + +- `pdm release`: Release a new Python package with an updated version. + +## Development + +The next steps should be followed during development: + +- `git checkout -b new-branch-name` to create a new branch and then modify the code. +- `pdm formatting` to auto-format the code and docstrings. +- `pdm checks` to apply all checks. +- `pdm tests` to run the tests. +- `pdm docs serve` if you updated the documentation or the project dependencies to check that everything looks as expected. + +## Commit message convention + +Commit messages follow conventions based on the [Angular +style](https://gist.github.com/stephenparish/9941e89d80e2bc58a153#format-of-the-commit-message). + +### Structure + +```bash +(): + + + +