Skip to content

Commit 6795634

Browse files
committed
Fix some tests
1 parent 5407ece commit 6795634

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

.travis.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ language: python
44
python: 3.8
55
cache: pip
66
before_install: pip install --upgrade pip setuptools six
7-
install: pip install -r requirements.txt
7+
install: pip install black flake8
88
before_script:
9-
- black --check . || true
10-
- IGNORE=E123,E203,E265,E266,E302,E401,E402,E712,E731,E741,E743,F811,F841,W291,W293,W503
11-
- flake8 . --count --ignore=$IGNORE --max-complexity=25 --max-line-length=127 --show-source --statistics
12-
script:
9+
- black --check .
10+
- flake8 --ignore=E203,W503 --max-complexity=25 --max-line-length=120 --statistics --count .
1311
- scripts/validate_filenames.py # no uppercase, no spaces, in a directory
12+
- pip install -r requirements.txt # fast fail on black, flake8, validate_filenames
13+
script:
1414
- mypy --ignore-missing-imports .
1515
- pytest --doctest-modules --cov-report=term-missing:skip-covered --cov=. .
1616
after_success:

data_structures/binary_tree/treap.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# flake8: noqa
2+
13
from random import random
24
from typing import Tuple
35

@@ -128,19 +130,19 @@ def interactTreap(root, args):
128130
129131
>>> root = interactTreap(None, "+1")
130132
>>> inorder(root)
131-
1
133+
1
132134
>>> root = interactTreap(root, "+3 +5 +17 +19 +2 +16 +4 +0")
133135
>>> inorder(root)
134-
0 1 2 3 4 5 16 17 19
136+
0 1 2 3 4 5 16 17 19
135137
>>> root = interactTreap(root, "+4 +4 +4")
136138
>>> inorder(root)
137-
0 1 2 3 4 4 4 4 5 16 17 19
139+
0 1 2 3 4 4 4 4 5 16 17 19
138140
>>> root = interactTreap(root, "-0")
139141
>>> inorder(root)
140-
1 2 3 4 4 4 4 5 16 17 19
142+
1 2 3 4 4 4 4 5 16 17 19
141143
>>> root = interactTreap(root, "-4")
142144
>>> inorder(root)
143-
1 2 3 5 16 17 19
145+
1 2 3 5 16 17 19
144146
>>> root = interactTreap(root, "=0")
145147
Unknown command
146148
"""

maths/collatz_sequence.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def collatz_sequence(n: int) -> List[int]:
1818
Traceback (most recent call last):
1919
...
2020
Exception: Sequence only defined for natural numbers
21-
>>> collatz_sequence(43) . # doctest: +NORMALIZE_WHITESPACE
21+
>>> collatz_sequence(43) # doctest: +NORMALIZE_WHITESPACE
2222
[43, 130, 65, 196, 98, 49, 148, 74, 37, 112, 56, 28, 14, 7,
2323
22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]
2424
"""

maths/prime_sieve_eratosthenes.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
Sieve of Eratosthenes
33
44
Input : n =10
5-
Output : 2 3 5 7
5+
Output: [2, 3, 5, 7]
66
77
Input : n = 20
8-
Output: 2 3 5 7 11 13 17 19
8+
Output: [2, 3, 5, 7, 11, 13, 17, 19]
99
1010
you can read in detail about this at
1111
https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
1212
"""
1313

1414

15-
def prime_sieve_eratosthenes(num):
15+
def prime_sieve_eratosthenes(num: int) -> list:
1616
"""
1717
print the prime numbers up to n
1818
1919
>>> prime_sieve_eratosthenes(10)
20-
2 3 5 7
20+
[2, 3, 5, 7]
2121
>>> prime_sieve_eratosthenes(20)
22-
2 3 5 7 11 13 17 19
22+
[2, 3, 5, 7, 11, 13, 17, 19]
2323
"""
2424

2525
primes = [True for i in range(num + 1)]
@@ -31,12 +31,10 @@ def prime_sieve_eratosthenes(num):
3131
primes[i] = False
3232
p += 1
3333

34-
for prime in range(2, num + 1):
35-
if primes[prime]:
36-
print(prime, end=" ")
34+
return primes
3735

3836

3937
if __name__ == "__main__":
4038
num = int(input())
4139

42-
prime_sieve_eratosthenes(num)
40+
print(prime_sieve_eratosthenes(num))

0 commit comments

Comments
 (0)