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/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..8a43b4b9b --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers 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, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at kwk236@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ 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/LICENSE b/LICENSE new file mode 100644 index 000000000..76e14882e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Keon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. 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 ed7e0b468..65caeb5ca 100644 --- a/README.md +++ b/README.md @@ -1,205 +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) + +