Commit Graph

2823 Commits

Author SHA1 Message Date
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
cclauss
2fb3beeaf1 Fix error message and format with python/black (#1025)
@SandersLin Your review please?
2019-07-16 10:56:28 +05:30
Sanders Lin
1e55bfd4da Create climbing_stairs.py (#1002)
a simple dp problem seen on LeetCode:  https://leetcode.com/problems/climbing-stairs/
2019-07-15 18:17:41 +02:00
obelisk0114
3b2738ed89 Add rotate matrix problem (#1021)
* Add rotate matrix problem

* Fix doctest

* Adding return matrix to enable doctest
2019-07-15 08:48:35 +02:00
obelisk0114
628794d89d Add combinations (#1015)
* Update Bucket Sort time complexity analysis

* Add combinations

* Adding doctest

* Fix doctest problem
2019-07-14 07:45:54 +02:00
Rakshit Parashar
0d61539883 Log_likelihood update (#1008)
* Add files via upload

This is a simple exploratory notebook that heavily expolits pandas and seaborn

* Update logistic_regression.py

* Update logistic_regression.py

* Rename Food wastage analysis from 1961-2013 (FAO).ipynb to other/Food wastage analysis from 1961-2013 (FAO).ipynb

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py

* Update logistic_regression.py
2019-07-13 21:54:38 +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
Sanders Lin
7271c0d64a Update rod_cutting.py (#995)
* Update rod_cutting.py

A hopefully clearer implementation without dependence on global variables.

* Update rod_cutting.py

added doctests

* Update rod_cutting.py

* Update rod_cutting.py
2019-07-13 09:12:54 +02:00
Sanders Lin
7a6ebb85a2 Update edit_distance.py (#1001)
added bottom up method.
2019-07-13 09:10:02 +02:00
Sanders Lin
1e0b33d3dd Update 3n+1.py (#996)
* Update 3n+1.py

Made variable names more meaningful and removed nested functions.

* Update 3n+1.py

* Update 3n+1.py

* Update 3n+1.py
2019-07-13 09:04:43 +02:00
obelisk0114
1dc9ec8fb2 Update Bucket Sort time complexity analysis (#918) 2019-07-12 23:16:14 +08:00
FrogBattle
f2eb965604 Update ~script.py (#990)
Changing the boolean expression avoids the use of a continue statement.
This way the code becomes easier/faster to compute on lower level and it has a
better coding style.
2019-07-11 18:21:48 +02:00
Sanders Lin
c2f2fa8b23 Update abs_Min.py (#1004)
* Update abs_Min.py

* Create __init__.py

* Rename abs_Min.py to abs_min.py

* Update abs_min.py
2019-07-11 18:20:41 +02:00
Alfonso Rodríguez Pereira
5f991f7740 #315 Renamed all files to snake_case (#993) 2019-07-11 11:16:42 +02:00
Sanders Lin
b79a197e8c Update abs_Max.py (#997)
* Update abs_Max.py

fix docstring for doctest to work properly (add space after >>>)

* Update abs_Max.py
2019-07-11 06:43:03 +02:00
Sanders Lin
37fbd8ca2e Update average_median.py (#998)
added doctest, fixed TypeError: list indices must be integers or slices, not float error due to number/2 producing float as index.
2019-07-10 22:38:10 +02:00
PatOnTheBack
897f1d0fb4 Improved Formatting and Style of Math Algos (#960)
* Improved Formatting and Style

I improved formatting and style to make PyLama happier.

Linters used:

- mccabe
- pep257
- pydocstyle
- pep8
- pycodestyle
- pyflakes
- pylint
- isort

* Create volume.py

This script calculates the volumes of various shapes.

* Delete lucasSeries.py

* Revert "Delete lucasSeries.py"

This reverts commit 64c19f7a6c.

* Update lucasSeries.py
2019-07-10 22:09:24 +02:00
PatOnTheBack
2ad5be9919 Modified Docstrings to Fix Errors (#975)
I modified the Docstrings at the beginning of the file to fix D400, W0105, and E402.
2019-07-10 22:00:30 +02:00
Shoujue Xu
34dee749a7 add canny edge detection algorithm and modify sobel_filter (#991)
* add gaussian filter algorithm and lena.jpg

* add img_convolve algorithm and sobel_filter

* add canny edge detection algorithm and modify sobel_filter

* format to avoid the backslashes
2019-07-10 22:41:05 +08:00
PatOnTheBack
add1aef064 Rename average.py to average_mean.py (#939)
'average.py' is ambiguous. There are several kinds of averages, so 'average_mean.py' is a more precise name.
2019-07-10 07:21:04 +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
Dharni0607
c85312da89 updates in closest pair of points algorithm (#979)
* updated closest pair of points (n*(logn)^2) to (n*logn)
2019-07-09 19:50:43 +04:30
Jasper
8b2d1b7f50 added decimal to hexadecimal conversion (#977)
* added decimal to hexadecimal conversion

* fixed error occuring as more digits were needed
2019-07-09 09:03:18 +02:00
Shoujue Xu
e2d9953952 convolve and sobel (#971)
* add gaussian filter algorithm and lena.jpg

* add img_convolve algorithm and sobel_filter
2019-07-08 22:56:26 +05:30
Animesh Singh
32d5c1a9b2 Project Euler Problem #13 Python Solution (#935)
* Create text file for numbers

* Create sol2.py

* Pythonic version of Problem #16 solution

* Update sol2.py

* Valid Python code for Python version 2-3

* Update sol2.py
2019-07-09 00:58:58 +08:00
cclauss
78cd3df3fc Update CONTRIBUTING.md to match #964 (#969)
* Update CONTRIBUTING.md to match #964

Blocked by #964

* Do not modify README or DIRECTORY file.

* Update CONTRIBUTING.md
2019-07-08 23:38:47 +08: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
PatOnTheBack
2b365284c8 Removed Unnecessary Assignment for 'error' Var (#920)
`error = abs(f(a))` was declared on line 24 and line 32. It is unnecessary to have in both places.
I removed the second instance since it wastes resources to keep redefining the variable inside the for loop.
This fixes an [issue found by lgtm](66c4afbd0f/files/maths/newton_raphson.py)
2019-07-07 23:45:42 +08:00
Hector S
234b0a77c4 Simplied password_generator.py (#968)
* 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

* Added main() function and simplified password generation.

* Modified password_generator.py file according to suggestions in #968
2019-07-07 17:17:38 +02:00
Shahabaldin Mohammadi
9532492728 added enigma machine algorithm (#932) 2019-07-07 12:19:15 +05:30
Aditi Agarwal
4ff2a9dd4e minimax (#947)
* minimax.py

minimax algorithm is used for game like tic tac toe. It traces the path and selects the optimal move.

* minimax.py

Minimax is used in decision making and game theory to find the optimal move for a player, when your opponent also plays optimally. It is widely used in games like Tic-Tac-Toe, Chess.

* Delete minimax.py

* Update minimax.py

* Minimax is a backtracking algorithm that is used in game theory to find the optimal move for a player, assuming that your opponent also plays optimally
2019-07-07 06:59:58 +02:00
PatOnTheBack
26df2aab1e Removed Unused import sys (#922)
I removed `import sys` because it is not used in the program.
This addresses a [recommendation from lgtm](66c4afbd0f/files/ciphers/caesar_cipher.py)
2019-07-06 23:35:12 +08:00
Erfan Alimohammadi
69bed59036
Fix backtrack time complexity (#965)
* Update backtracking/all_permutations.py
2019-07-06 20:01:52 +04:30
Erfan Alimohammadi
781b7f86e7 Fix readme and duplicate (#967)
* Fix typo

* Add all_permutations algorithm to backtracking directory

* Update backtracking and D&C algorithms in README

Update backtracking and divide_and_conquer algorithms in README

* Remove the duplicated file
2019-07-06 20:02:06 +05:30
Erfan Alimohammadi
839160f83a Generate all permutations of a sequence, using backtracking (#962)
* Fix typo

* Add all_permutations algorithm to backtracking directory
2019-07-06 16:19:36 +03:00
Erfan Alimohammadi
cc4cf3ece7
Generate all subsequences using backtracking (#961)
* Add all_subsequences to backtracking directory
2019-07-06 17:43:50 +04:30
Anup Kumar Panwar
1951b4ca79
Update FUNDING.yml 2019-07-06 14:04:27 +05:30
Anup Kumar Panwar
aa663037f6
Create FUNDING.yml 2019-07-06 13:47:56 +05:30
Anup Kumar Panwar
1161393b39 updated CONTRIBUTING.md 2019-07-06 11:21:08 +05:30
Anup Kumar Panwar
b23834062c refactor 2019-07-06 11:14:55 +05:30
Anup Kumar Panwar
f30f8493e6 Updated README 2019-07-06 11:12:26 +05:30
Anup Kumar Panwar
4e413c0183 Updated README 2019-07-06 11:11:20 +05:30
Hetal Kuvadia
831558d38d #945 Backtracking Algorithms (#953)
* Adding nqueens.py for backtracking

* Adding sum_of_subsets.py for backtracking

* Update nqueens.py

* Rename nqueens.py to n_queens.py

* Deleting /other/n_queens.py
2019-07-05 14:18:36 +05:30
Dhandarah
afb98e6c23 KNN (#944)
Creates an example of KNN algorithm using sklearn library.
2019-07-05 14:17:18 +05:30
Jarred Allen
506bb5ccfe Add Red-Black Binary Search Trees (#954)
* Wrote most of an rbt, missing just removal

* Added some convenience methods.

* Added a color method

* Wrote code to delete, but has issues :(

* Fixed a bug in Red-Black trees

* Fixed bug in tree color validation and delete repairing

* Clean up == comparison to None
2019-07-05 14:13:16 +05:30
PatOnTheBack
1c9d995b9e Implement Three New Algorithms (#948)
* Create average_median.py

I created a program to calculate the median of a list of numbers.

* Changed Odd to Even in String

* Create decimal_to_binary.py

- Added 'conversions' folder.
- Created a decimal to binary converter.

* Implemented Decimal to Octal Algorithm

- I created a decimal to octal converter based on the converter in the TheAlgorithms/Python project.
- I added two newlines to make the output of decimal_to_binary.py better.
2019-07-05 14:06:48 +05:30
PatOnTheBack
217615abf6 Removed Unused Variables (#949)
- Removed two unused variables.
- Changed `a` to `_` since the `a` variable is never used.

This addresses [3 alerts from lgtm](d55bbcd204/files/sorts/Odd-Even_transposition_parallel.py).
2019-07-05 14:04:46 +05:30
Shoujue Xu
408c5deb3a add gaussian filter algorithm and lena.jpg (#955) 2019-07-05 13:50:11 +05:30
Hector S
05fc7f8a33 Added '~script.py' to ignore files and updated DIRECTORY.md (#926)
* 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

* Added '~script.py' to ignore files and updated DIRECTORY.md
2019-07-04 23:18:57 +08:00