mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-27 23:11:09 +00:00
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
This commit is contained in:
parent
9f8953dc0c
commit
f7ac8b5ed0
38
.travis.yml
38
.travis.yml
|
@ -9,31 +9,19 @@ before_script:
|
||||||
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
- flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
script:
|
script:
|
||||||
- mypy --ignore-missing-imports .
|
- mypy --ignore-missing-imports .
|
||||||
#- IGNORE="data_structures,file_transfer_protocol,graphs,machine_learning,maths,neural_network,project_euler"
|
- pytest . --doctest-modules
|
||||||
#- pytest . --doctest-modules --ignore=${IGNORE}
|
--ignore=data_structures/stacks/balanced_parentheses.py
|
||||||
- pytest --doctest-modules
|
--ignore=data_structures/stacks/infix_to_postfix_conversion.py
|
||||||
arithmetic_analysis
|
--ignore=file_transfer_protocol/ftp_send_receive.py
|
||||||
backtracking
|
--ignore=file_transfer_protocol/ftp_client_server.py
|
||||||
boolean_algebra
|
--ignore=machine_learning/linear_regression.py
|
||||||
ciphers
|
--ignore=machine_learning/perceptron.py
|
||||||
compression
|
--ignore=machine_learning/random_forest_classification/random_forest_classification.py
|
||||||
conversions
|
--ignore=machine_learning/random_forest_regression/random_forest_regression.py
|
||||||
digital_image_processing
|
--ignore=maths/abs_min.py
|
||||||
divide_and_conquer
|
--ignore=maths/binary_exponentiation.py
|
||||||
dynamic_programming
|
--ignore=maths/lucas_series.py
|
||||||
graphs
|
--ignore=maths/sieve_of_eratosthenes.py
|
||||||
hashes
|
|
||||||
linear_algebra_python
|
|
||||||
matrix
|
|
||||||
networking_flow
|
|
||||||
neural_network
|
|
||||||
other
|
|
||||||
project_euler
|
|
||||||
searches
|
|
||||||
sorts
|
|
||||||
strings
|
|
||||||
traversals
|
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- python scripts/build_directory_md.py
|
- python scripts/build_directory_md.py
|
||||||
- cat DIRECTORY.md
|
- cat DIRECTORY.md
|
||||||
|
|
|
@ -18,8 +18,9 @@ def solution():
|
||||||
2. a**2 + b**2 = c**2
|
2. a**2 + b**2 = c**2
|
||||||
3. a + b + c = 1000
|
3. a + b + c = 1000
|
||||||
|
|
||||||
>>> solution()
|
# The code below has been commented due to slow execution affecting Travis.
|
||||||
31875000
|
# >>> solution()
|
||||||
|
# 31875000
|
||||||
"""
|
"""
|
||||||
for a in range(300):
|
for a in range(300):
|
||||||
for b in range(400):
|
for b in range(400):
|
||||||
|
|
|
@ -21,8 +21,8 @@ def solution():
|
||||||
1. a**2 + b**2 = c**2
|
1. a**2 + b**2 = c**2
|
||||||
2. a + b + c = 1000
|
2. a + b + c = 1000
|
||||||
|
|
||||||
>>> solution()
|
#>>> solution()
|
||||||
31875000
|
#31875000
|
||||||
"""
|
"""
|
||||||
return [
|
return [
|
||||||
a * b * c
|
a * b * c
|
||||||
|
|
|
@ -42,8 +42,9 @@ def sum_of_primes(n):
|
||||||
def solution(n):
|
def solution(n):
|
||||||
"""Returns the sum of all the primes below n.
|
"""Returns the sum of all the primes below n.
|
||||||
|
|
||||||
>>> solution(2000000)
|
# The code below has been commented due to slow execution affecting Travis.
|
||||||
142913828922
|
# >>> solution(2000000)
|
||||||
|
# 142913828922
|
||||||
>>> solution(1000)
|
>>> solution(1000)
|
||||||
76127
|
76127
|
||||||
>>> solution(5000)
|
>>> solution(5000)
|
||||||
|
|
|
@ -31,8 +31,9 @@ def prime_generator():
|
||||||
def solution(n):
|
def solution(n):
|
||||||
"""Returns the sum of all the primes below n.
|
"""Returns the sum of all the primes below n.
|
||||||
|
|
||||||
>>> solution(2000000)
|
# The code below has been commented due to slow execution affecting Travis.
|
||||||
142913828922
|
# >>> solution(2000000)
|
||||||
|
# 142913828922
|
||||||
>>> solution(1000)
|
>>> solution(1000)
|
||||||
76127
|
76127
|
||||||
>>> solution(5000)
|
>>> solution(5000)
|
||||||
|
|
|
@ -45,8 +45,9 @@ def solution():
|
||||||
"""Returns the value of the first triangle number to have over five hundred
|
"""Returns the value of the first triangle number to have over five hundred
|
||||||
divisors.
|
divisors.
|
||||||
|
|
||||||
>>> solution()
|
# The code below has been commented due to slow execution affecting Travis.
|
||||||
76576500
|
# >>> solution()
|
||||||
|
# 76576500
|
||||||
"""
|
"""
|
||||||
tNum = 1
|
tNum = 1
|
||||||
i = 1
|
i = 1
|
||||||
|
|
|
@ -39,8 +39,9 @@ def solution():
|
||||||
"""Returns the value of the first triangle number to have over five hundred
|
"""Returns the value of the first triangle number to have over five hundred
|
||||||
divisors.
|
divisors.
|
||||||
|
|
||||||
>>> solution()
|
# The code below has been commented due to slow execution affecting Travis.
|
||||||
76576500
|
# >>> solution()
|
||||||
|
# 76576500
|
||||||
"""
|
"""
|
||||||
return next(
|
return next(
|
||||||
i for i in triangle_number_generator() if count_divisors(i) > 500
|
i for i in triangle_number_generator() if count_divisors(i) > 500
|
||||||
|
|
|
@ -30,8 +30,9 @@ def solution(n):
|
||||||
n → n/2 (n is even)
|
n → n/2 (n is even)
|
||||||
n → 3n + 1 (n is odd)
|
n → 3n + 1 (n is odd)
|
||||||
|
|
||||||
>>> solution(1000000)
|
# The code below has been commented due to slow execution affecting Travis.
|
||||||
{'counter': 525, 'largest_number': 837799}
|
# >>> solution(1000000)
|
||||||
|
# {'counter': 525, 'largest_number': 837799}
|
||||||
>>> solution(200)
|
>>> solution(200)
|
||||||
{'counter': 125, 'largest_number': 171}
|
{'counter': 125, 'largest_number': 171}
|
||||||
>>> solution(5000)
|
>>> solution(5000)
|
||||||
|
|
|
@ -47,8 +47,9 @@ def collatz_sequence(n):
|
||||||
def solution(n):
|
def solution(n):
|
||||||
"""Returns the number under n that generates the longest Collatz sequence.
|
"""Returns the number under n that generates the longest Collatz sequence.
|
||||||
|
|
||||||
>>> solution(1000000)
|
# The code below has been commented due to slow execution affecting Travis.
|
||||||
{'counter': 525, 'largest_number': 837799}
|
# >>> solution(1000000)
|
||||||
|
# {'counter': 525, 'largest_number': 837799}
|
||||||
>>> solution(200)
|
>>> solution(200)
|
||||||
{'counter': 125, 'largest_number': 171}
|
{'counter': 125, 'largest_number': 171}
|
||||||
>>> solution(5000)
|
>>> solution(5000)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user