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