diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..a5f7fcee8 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[report] +omit = + */python?.?/* + */site-packages/nose/* + *__init__* diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 000000000..1eb737ecd --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,36 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python application + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + python -m pytest diff --git a/.gitignore b/.gitignore index 43ae0e2a6..5152c3d1b 100755 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,19 @@ __pycache__/ *.py[cod] +*.iml +*.xml +.idea/ +.cache/ +.pytest_cache/ +.coverage +# Setuptools distribution folder. +/dist/ +# Python egg metadata, regenerated from source files by setuptools. +/*.egg-info +/*.egg +# docs +build/ +pythonenv3.8/ +.vscode/ +# Ignoring the virtual Environment when using GitHub Codespaces +.venv/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..94607d486 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +group: travis_latest +dist: xenial # Travis CI's default distro +language: python +cache: + directories: + - $HOME/.cache/pip +matrix: + include: + - python: 3.6 + env: TOX_ENV=py36 + - python: 3.7 + env: TOX_ENV=py37 +install: + - pip install -r test_requirements.txt +before_script: + # run black to check if some files would need reformatting + - black --check . || true + # stop the build if there are Python syntax errors or undefined names + - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics +script: + # Check python install package + - pip install -e . + - tox -e $TOX_ENV + # Check python uninstall package + - pip uninstall -y algorithms +notifications: + on_success: change + on_failure: change # `always` will be the setting once code changes slow down diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..6eac6c029 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,66 @@ +# Contributing + +We love pull requests from everyone. By contributing to this repository, you +agree to abide by the [Code of Conduct](CODE_OF_CONDUCT.md). + +## Get Started + +* First [fork][fork] the repository and then clone it using: + + git clone git@github.com:your-username/algorithms.git + +* After that create a branch for your changes. For example: + * add_XXX if you will add new algorithms or data structures. + * fix_XXX if you will fix a bug on a certain algorithm or data structure. + * test_XXX if you wrote a test/s. + * doc_XXX if you added to or edited documentation. + +You may contribute by: +- implementing new algorithms in the repo. Be sure to keep it under +right section (e.g. [array](array), [dp](dp), etc). Make a new section for it if +it doesn't fall under any section. Make sure that your implementation works. +- optimizing or improving the existing algorithms. +- adding a different solution for the problem. +- finding and fixing bugs. +- adding examples to explain the algorithms better. +- adding test cases. +- improving documentation. + +## Pull Requests +Push to your fork and [submit a pull request][pr]. + +We will review and may suggest some changes or improvements or alternatives. +Some things that will increase the chance that your pull request is accepted: + +* All algorithms should be written in **Python 3**. +(There are a few algorithms still in _Python 2_ syntax. You can start by converting +[those][issue120] to _Python 3_.) +* Write clean and understandable code. +* Properly comment the code and briefly explain what the algorithm is doing in the [docstrings][docstr]. +* You may also explain the output using a minimal example. +* Try to also include a couple of test cases for the algorithm. +* Write a [good commit message][commit]. + + +## Issues +Submit a [new issue][newissue] if there is an algorithm to add, or if a bug was found in an existing algorithm. Before submitting a new issue please review the [existing issues][issues] to avoid creating duplicates. Also, consider resolving current issues or contributing to the discussion on an issue. + +## Collaborators +You can ask for any help or clarifications from the collaborators. +[Keon Kim](https://github.com/keon) + +[Rahul Goswami](https://github.com/goswami-rahul) + +[Ankit Agarwal](https://github.com/ankit167) + +[Hai Hoang Dang](https://github.com/danghai) + +[Saad](https://github.com/SaadBenn) + +[fork]: https://help.github.com/articles/fork-a-repo/ +[docstr]: https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings +[commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html +[pr]: https://github.com/keon/algorithms/compare/ +[newissue]: https://github.com/keon/algorithms/issues/new +[issue120]: https://github.com/keon/algorithms/issues/120 +[issues]: https://github.com/keon/algorithms/issues/ diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 000000000..50af9b9c9 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,3 @@ +include README.md +include LICENSE +include algorithms/* diff --git a/README.md b/README.md index 9b09e003b..65caeb5ca 100644 --- a/README.md +++ b/README.md @@ -1,212 +1,424 @@ +[](https://badge.fury.io/py/algorithms) +[](https://www.codetriage.com/keon/algorithms) +[](https://travis-ci.org/keon/algorithms) +[](https://coveralls.io/github/keon/algorithms?branch=master) + +