Commit Graph

55 Commits

Author SHA1 Message Date
Dhruv Manilawala
b97529dd88
Move validate_solutions and add durations flag to pytest.ini (#3704)
* Move PE validate_solutions to scripts/ directory

* Update pytest.ini file with durations settings

* Remove codespell and autoblack workflow file

* Dependent changes to test config files

* Update pytest.ini
2020-10-24 19:07:33 +05:30
Dhruv
5cb41e7820
Create GitHub action only for Project Euler (#3378)
* Add GitHub action for Project Euler only

* Add second job for Project Euler

* Remove Project Euler jobs from Travis CI

* Fix typo for actions/setup-python

* Rename the workflow file

* Change name of file in workflow

* Remove comments from Travis config file
2020-10-17 08:23:17 +05:30
Dhruv
34d63d5155
Fix Travis CI slow build on Project Euler Solution job (#3262)
* Fix Travis CI long run for validate_solutions

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-10-13 22:43:40 +05:30
Dhruv
29b32d3553
Improve validate solutions script & fix pre-commit error (#3253)
* Trying to time every solution

* Proposal 2 for timing PE solutions:

- Use pytest fixture along with --capture=no flag to print out the
  top DURATIONS slowest solution at the end of the test sessions.
- Remove the print part and try ... except ... block from the test
  function.

* Proposal 3 for timing PE solutions:

Completely changed the way I was performing the tests. Instead of
parametrizing the problem numbers and expected output, I will
parametrize the solution file path.

Steps:
- Collect all the solution file paths
- Convert the paths into a Python module
- Call solution on the module
- Assert the answer with the expected results

For assertion, it was needed to convert the JSON list object to
Python dictionary object which required changing the JSON file itself.

* Add type hints for variables

* Fix whitespace in single_qubit_measure
2020-10-13 15:41:12 +05:30
Dhruv
69f9283825
Start running validate_solutions script for Travis CI (#3215)
* Removed print error_msgs at the end of test:

This was done only to reduce the message clutter produced by 60
failing tests. As that is fixed, we can produce the traceback in
short form and allow pytest to print the captured error message
output at the end of test.

* Start validate_solutions script for Travis CI

I am separating out the solution testing and doctest as validating
the solutions for the current number of solutions present is
taking 2 minutes to run.
2020-10-12 11:29:39 +05:30
Christian Clauss
ddfa9e4f22
Travis CI: Remove redundant tests (#2523)
* Travis CI: Remove redundant tests

* fixup! before_script

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-30 19:26:38 +02:00
Dhruv
0a42ae9095
Fix all errors mentioned in pre-commit run (#2512)
* Fix all errors mentioned in pre-commit run:

- Fix end of file
- Remove trailing whitespace
- Fix files with black
- Fix imports with isort

* Fix errors
2020-09-30 10:38:00 +02:00
Dhruv
ceacfc6079
Add algorithm for testing Project Euler solutions (#2471)
* Add file for testing Project Euler solutions

* Remove the importlib import

* Update project_euler/solution_test.py

Co-authored-by: Christian Clauss <cclauss@me.com>

* Small tweaks to project_euler/solution_test.py

* Test Project Euler solutions through Travis

* Improved testing for Project Euler solutions:

- Renamed file so that it isn't picked up by pytest
- Fail fast on validating solutions through Travis CI

* Update validate_solutions.py

* Use namedtuple for input parameters and answer

- Remove logging
- Remove unnecessary checks for PROJECT_EULER_PATH as Travis CI
  picks up the same path

* Fix flake8 errors: line too long

* Small tweaks to validate_solutions.py

* Add all answers & back to using dictionary

* Using pytest for testing Project Euler solutions

- As we want to fail fast on testing solutions, we need to test using
  this script first before we use tests written by the author.
- As pytest stops testing as soon as it receives a traceback, we need to
  use pytest-subtests to tell pytest to test all the iterations for the
  function with given parameters.

* Print error messages in oneline format

* Separated answers into a separate file:

- Add custom print function to print all the error messages at the
  end of all the tests
- Let Travis skip if this failed

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-28 08:18:19 +02:00
Christian Clauss
9200a2e543
from __future__ import annotations (#2464)
* from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! from __future__ import annotations

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-09-23 13:30:13 +02:00
Dhruv
6e6a49d19f
Config Travis CI for two jobs (#2463)
* Testing Travis CI configuration for project Euler

* Fix: Installing mypy and pytest-cov for testing

* Remove unnecessary checks for project_euler job

* Removing branches section

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

Co-authored-by: Christian Clauss <cclauss@me.com>
2020-09-23 13:24:32 +02:00
Christian Clauss
e77600638d
Travis CI: Identify our ten slowest pytests (#2350)
* Travis CI: Identify our ten slowest tests

https://howchoo.com/g/mtblodnjzjc/how-to-measure-unit-test-execution-times-in-pytest helps us to find the individual tests that are slowing down our Travis CI checks.

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-08-25 15:47:06 +02:00
Christian Clauss
9316e7c014
Set the Python file maximum line length to 88 characters (#2122)
* flake8 --max-line-length=88

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-16 10:09:19 +02:00
mateuszz0000
e553f4bf11
Added travis notifications only on fail (#2091)
* Added travis notifications only on fail

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-10 12:40:52 +02:00
mateuszz0000
1e7df7f77a
Errors notifications under pull requests (#2081)
* Added error comments under pull requests

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-06-08 14:11:01 +02:00
Christian Clauss
dc4049ee28
.travis.yml: Revert to using autoblack (#2033)
* .travis.yml: Revert to using autoblack

Our autoblack GitHub Action will get us to black compliance without forcing each contributor to learn about, install, and use psf/black on every pull request.

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-24 20:38:28 +05:30
Christian Clauss
1f8a21d727
Tighten up psf/black and flake8 (#2024)
* Tighten up psf/black and flake8

* Fix some tests

* Fix some E741

* Fix some E741

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-22 08:10:11 +02:00
Christian Clauss
3d9bb051a8
Travis CI: Strict flake8 (#1962)
* Travis CI: Strict flake8

Turn the screws all the way down.

* updating DIRECTORY.md

* Switch from flake8 --select to --ignore

* Quotes

* IGNORE=E123,E203,E265,E266,E302,E401,E402,E712,E731,E741,E743,F811,F841,W291,W293,W503

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-10 08:06:42 +02:00
Christian Clauss
8b55a143fa
Travis CI: lint for useless backslashes (#1961)
* Travis CI: lint for useless backslashes

* updating DIRECTORY.md

* flake8  --max-complexity=25

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-09 13:24:25 +02:00
Christian Clauss
6acd7fb5ce
Wrap lines that go beyond GitHub Editor (#1925)
* Wrap lines that go beyond GiHub Editor

* flake8 --count --select=E501 --max-line-length=127

* updating DIRECTORY.md

* Update strassen_matrix_multiplication.py

* fixup! Format Python code with psf/black push

* Update decision_tree.py

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-05-01 23:36:35 +02:00
Christian Clauss
8cb957f893
Blacken one_dimensional.py (#1911)
* Blacken one_dimensional.py

* updating DIRECTORY.md

* Travis CI: Upgrade to Ubuntu 20.04 LTS Focal

Ubuntu 20.04 LTS (Focal Fossa) https://releases.ubuntu.com/focal

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-04-27 18:40:46 +02:00
Christian Clauss
ab3400bfad
Travis CI: Fix Travis linter errors (#1802)
* Travis CI: Fix Travis linter errors

* fixup! Format Python code with psf/black push

* Update .travis.yml

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2020-03-14 23:55:13 +01:00
Christian Clauss
652b891a75
Travis CI: Upgrade to Python 3.8 (#1783)
* Travis CI: Upgrade to Python 3.8

* updating DIRECTORY.md

* Tensorflow is not yet compatible with Python 3.8

* Disable k_means_clustering_tensorflow.py

* updating DIRECTORY.md

* Disable gan.py

* updating DIRECTORY.md

* Disable input_data.py

* updating DIRECTORY.md

* pip install a current version of six
2020-02-23 04:23:00 +01:00
Christian Clauss
670f952aa6
Travis CI: Don’t allow bare exceptions (#1734)
* Travis CI: Don’t allow bare exceptions

* fixup! Format Python code with psf/black push

* except IOError:

* except IOError:

* Update hamming_code.py

* IndexError

* Get rid of the nonsense logic

Co-authored-by: John Law <johnlaw.po@gmail.com>
2020-02-07 22:02:08 +02:00
Hocnonsense
81ae5adcc8 Update binary_search_tree.py (#1339)
* Update binary_search_tree.py

remove some bugs

* Update binary_search_tree.py

* Update binary_search_tree.py

* Update binary_search_tree.py

* Update binary_search_tree.py

* Update binary_search_tree.py

* Update binary_search_tree.py

* testlist = (8, 3, 6, 1, 10, 14, 13, 4, 7)

* Update .travis.yml

Co-authored-by: Christian Clauss <cclauss@me.com>
2019-12-21 01:44:31 +01:00
Mantas Zimnickas
5616fa9e62 Add pytest-cov (#1578)
* Add pytest-cov

Also added coverage report in .travis.yml file.

* updating DIRECTORY.md

* Sort by missing statements

* sort = Cover
2019-11-17 19:37:58 +01:00
Christian Clauss
b838f1042c Fix indentation contains tabs (flake8 E101,W191) (#1573) 2019-11-15 23:05:00 -08:00
Marvin M. Michum
8107548cc1 Travis CI: Write & print DIRECTORY.md on one line (#1542)
* travis test

* travis pull ID test

* get pr branch test

* retry pr build

* test pushing back - probable git error for origin 'not found'

* github auth?

* add .sh

* chmod

* add index update for permission fix

* run sh for script

* add all

* add pull directory

* fetch pr branch

* swap placement of adding commits

* rotate

* quit trying to update Travis

* formatting leftovers

* Travis CI: Write & print DIRECTORY.md on one line
2019-11-01 04:06:20 +01:00
Alfin_William
5c351d81bf Implementation of Hardy Ramanujan Algorithm in /maths (#1355)
* Implementation of Hardy Ramanujan Algorithm

* added docstrings

* added doctests

* Run Python black on the code

* Travis CI: Upgrade to Python 3.8

* Revert to Python 3.7
2019-10-19 06:02:38 +02:00
PatOnTheBack
6fa3c0b170 Add Flake8 F4 Tests to .travis.yml (#974)
* Add Flake8 F4 Tests to .travis.yml

F4 tests check for import errors. Implements issue #973

* Remove wildcard imports
2019-09-13 14:07:24 +02:00
Christian Clauss
55cea57ffa
Fix tests for file_transfer and perceptron.py (#1121) 2019-08-11 13:00:58 +02:00
Christian Clauss
91c3c98d2b
Rename file_transfer and linear_algebra (#1118)
* Rename file_transfer and linear_algebra

* Rename file_transfer and linear_algebra
2019-08-09 21:37:16 +02:00
AlexDvorak
9456e81437 Seperate client and server of FTP (#1106)
* added sample file to transfer

* split client and server into separate files

* client and server now work in python2

* server works on python3

* client works on python3

* allow configurable ONE_CONNECTION_ONLY for testing server

* allow testing of ftp server + client

* use f-strings

* removed single letter vars

* fixed bad quote marks

* clearer file handler names

* 'with open() as' syntax

* unicode and emojis in the test data

* s -> sock

* consistent comment spacing

* remove closing formalities

* swap in and out_file

* f-string

* if __name__ == '__main__':
2019-08-07 15:44:48 +02:00
Christian Clauss
561a41464f
Travis CI: Run each failing pytest in allow_failures mode (#1087)
* Travis CI: Run failing pytest in allow_failures mode

* Sync with master

* Sync with master
2019-08-06 21:53:12 +02:00
Christian Clauss
7b267e5e4f Fix data_structures to pass our Travis CI pytests (#1088)
* Fix data_structures to pass pytests

* Restore data_structures/stacks/__init__.py
2019-07-31 23:14:35 +08:00
Christian Clauss
a9ecdb33ca Validate Python filenames (#1086) 2019-07-30 15:32:13 +05:30
Christian Clauss
a0817bdcf0
Rewrite build_directory_md.py (#1076)
* Rewrite build_directory_md.py

* Regenerate DIRECTORY.md
2019-07-28 17:27:23 +02:00
Christian Clauss
3c8e9314b6 Travis CI: Add a flake8 test for unused imports (#1038) 2019-07-25 13:19:00 +05:30
Christian Clauss
93fdc9f2a1 Travis CI: Add pytest --doctest-modules maths (#1020)
* Travis CI: Add pytest --doctest-modules maths

* Update lucas_series.py

* Update lucas_series.py
2019-07-21 11:46:28 +05:30
Bruno Simas Hadlich
f7ac8b5ed0 Commented doctests that were causing slowness at Travis. (#1039)
* Added doctest and more explanation about Dijkstra execution.

* tests were not passing with python2 due to missing __init__.py file at number_theory folder

* Removed the dot at the beginning of the imported modules names because 'python3 -m doctest -v data_structures/hashing/*.py' and 'python3 -m doctest -v data_structures/stacks/*.py' were failing not finding hash_table.py and stack.py modules.

* Moved global code to main scope and added doctest for project euler problems 1 to 14.

* Added test case for negative input.

* Changed N variable to do not use end of line scape because in case there is a space after it the script will break making it much more error prone.

* Added problems description and doctests to the ones that were missing. Limited line length to 79 and executed python black over all scripts.

* Changed the way files are loaded to support pytest call.

* Added __init__.py to problems to make them modules and allow pytest execution.

* Added project_euler folder to test units execution

* Changed 'os.path.split(os.path.realpath(__file__))' to 'os.path.dirname()'

* Added Burrows-Wheeler transform algorithm.

* Added changes suggested by cclauss

* Fixes for issue 'Fix the LGTM issues #1024'.

* Added doctest for different parameter types and negative values.

* Fixed doctest issue added at last commit.

* Commented doctest that were causing slowness at Travis.

* Added comment with the reason for some doctest commented.

* pytest --ignore
2019-07-19 00:34:29 +02:00
cclauss
c2e8582abd
Travis CI: Add pytest --doctest-modules neural_network (#1028)
* neural_network/perceptron.py: Add if __name__ == '__main__':

* Remove tab indentation

* Add neural_network to the pytests
2019-07-18 13:10:52 +02:00
cclauss
7cdda931fd
Travis CI: Add pytest --doctest-modules graphs (#1018) 2019-07-17 06:07:25 +02:00
Bruno Simas Hadlich
267b5eff40 Added doctest and more explanation about Dijkstra execution. (#1014)
* Added doctest and more explanation about Dijkstra execution.

* tests were not passing with python2 due to missing __init__.py file at number_theory folder

* Removed the dot at the beginning of the imported modules names because 'python3 -m doctest -v data_structures/hashing/*.py' and 'python3 -m doctest -v data_structures/stacks/*.py' were failing not finding hash_table.py and stack.py modules.

* Moved global code to main scope and added doctest for project euler problems 1 to 14.

* Added test case for negative input.

* Changed N variable to do not use end of line scape because in case there is a space after it the script will break making it much more error prone.

* Added problems description and doctests to the ones that were missing. Limited line length to 79 and executed python black over all scripts.

* Changed the way files are loaded to support pytest call.

* Added __init__.py to problems to make them modules and allow pytest execution.

* Added project_euler folder to test units execution

* Changed 'os.path.split(os.path.realpath(__file__))' to 'os.path.dirname()'
2019-07-17 01:09:53 +02:00
Hector S
d72586c5f4 Updated ~script.py per #978 (#1013)
* Added print function into matrix_multiplication_addition.py and removed blank space in data_structures/binary tree directory

* Removed .vs/ folder per #893

* Rename matrix_multiplication_addition.py to matrix_operation.py

* Moved and renamed ~script.py to scripts/build_directory_md.py
Updated DIRECTORY.MD file

* Modified .travis.yml per suggestion in #1013

* Fixed typo per suggestions in #1013
2019-07-13 21:50:37 +02:00
cclauss
e6eaa078e2
Pytest the entire repo (#980)
* Pytest the entire repo

* Do each directory for now...

* YAML files hate tabs

* Add more requirements

* pip install opencv-python

* Comment out FTP

* Add pandas and sklearn to requirements

* Comment out FTP, graphs, machine_learning, maths, neural_network, project_euler

* Update .travis.yml

* Comment out Data structures

* if __name__ == "__main__":

* pytest --ignore=

* pytest .

* Update .travis.yml

* pytest . --doctest-modules --ignore=${IGNORE}

* Ignore --ignore because it just hangs
2019-07-10 06:59:39 +02:00
cclauss
b7f13d991c Travis CI: Run black, doctest, flake8, mypy, and pytest (#964)
* Travis CI: Add type checking with mypy

* Create requirements.txt

* script: mypy --ignore-missing-stubs=cv2,numpy .

* Delete requirements.txt

* script: mypy --ignore-missing-imports .

* Run doctests

* Disable doctest -v other/detecting_english_programmatically.py

* Pytest

* No |

* pytest || true

* Run black doctest flake8 mypy pytest

* after_success: Build Directory.md

* Typo in filename: Dictionary.txt --> dictionary.txt'

Discovered via doctest run in #964

* python -m doctest -v

* pip install black flake8 mypy pytest

* pytest --doctest-glob='*.py'

* pytest --doctest-modules

* pytest --doctest-modules ./sorts

* pytest --doctest-modules ./ciphers ./other ./searches ./sorts ./strings || true

* if __name__ == "__main__":

* if __name__ == "__main__":

* if __name__ == '__main__':

* if __name__ == '__main__':

* if __name__ == '__main__':

* Create requirements.txt

* Update requirements.txt

* if __name__ == "__main__":

* Lose the doctests

* if __name__ == '__main__':

* Remove print-a-tuple

* doctest: Added missing spaces

* Update tabu_search.py

* The >>> are not doctests so change to >>)

* Travis CI: Run black, doctest, flake8, mypy, and pytest

* Link to the separate DIRECTORY.md file

* Update README.md
2019-07-08 23:27:51 +08:00
cclauss
4fb4cb4fd1 Travis CI: Simplify the testing (#887)
* Travis CI: Simplify the testing

* flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics

* python: 3.7

* dist: xenial for python: 3.7

* Delete .lgtm.yml

These changes were created to get around the fact that Travis CI was not enabled on this repo.  Now that Travis is enabled, we can remove these modifications.

The problems are that:
1. [LGTM does not want us running flake8 on their infrstructure](https://discuss.lgtm.com/t/can-i-get-lgtm-to-run-flake8-tests/1445/6) and
2. when we do, it [does not work as expected](https://discuss.lgtm.com/t/tests-are-not-automatically-run-when-lgtm-yml-is-modified/1446/4).
2019-07-03 12:51:03 +05:30
cclauss
5b86928c4b Use ==/!= to compare str, bytes, and int literals (#767)
* Travis CI: Add more flake8 tests

* Use ==/!= to compare str, bytes, and int literals

./project_euler/problem_17/sol1.py:25:7: F632 use ==/!= to compare str, bytes, and int literals
			if i%100 is not 0:
      ^

* Use ==/!= to compare str, bytes, and int literals

* Update sol1.py
2019-05-16 19:26:46 +08:00
cclauss
ba759d9573
Add automated flake8 testing of pull requests
The owner of the this repo would need to go to https://travis-ci.org/profile and flip the repository switch __on__ to enable free automated flake8 testing of each pull request.  Flake8 will find bugs and code smells.
2017-11-25 00:10:39 +01:00
Anup Kumar Panwar
aa8485b4df Delete .travis.yml 2017-09-29 11:28:07 +05:30
Anup Kumar Panwar
8bae14ba1c Update .travis.yml 2017-09-29 11:22:32 +05:30