Skip to content

Commit 0889327

Browse files
committed
fixes
1 parent 6edfcf2 commit 0889327

File tree

5 files changed

+12
-48
lines changed

5 files changed

+12
-48
lines changed

ciphers/affine_cipher.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,15 @@ def check_keys(keyA, keyB, mode):
3333
if mode == "encrypt":
3434
if keyA == 1:
3535
sys.exit(
36-
"The affine cipher becomes weak when key "
37-
"A is set to 1. Choose different key"
36+
"The affine cipher becomes weak when key " "A is set to 1. Choose different key"
3837
)
3938
if keyB == 0:
4039
sys.exit(
41-
"The affine cipher becomes weak when key "
42-
"B is set to 0. Choose different key"
40+
"The affine cipher becomes weak when key " "B is set to 0. Choose different key"
4341
)
4442
if keyA < 0 or keyB < 0 or keyB > len(SYMBOLS) - 1:
4543
sys.exit(
46-
"Key A must be greater than 0 and key B must "
47-
f"be between 0 and {len(SYMBOLS) - 1}."
44+
"Key A must be greater than 0 and key B must " f"be between 0 and {len(SYMBOLS) - 1}."
4845
)
4946
if cryptomath.gcd(keyA, len(SYMBOLS)) != 1:
5047
sys.exit(
@@ -102,4 +99,4 @@ def get_random_key():
10299
import doctest
103100

104101
doctest.testmod()
105-
main()
102+
# main()

graphs/connected_components.py

+3-18
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,9 @@
55
66
"""
77

8-
test_graph_1 = {
9-
0: [1, 2],
10-
1: [0, 3],
11-
2: [0],
12-
3: [1],
13-
4: [5, 6],
14-
5: [4, 6],
15-
6: [4, 5],
16-
}
17-
18-
test_graph_2 = {
19-
0: [1, 2, 3],
20-
1: [0, 3],
21-
2: [0],
22-
3: [0, 1],
23-
4: [],
24-
5: [],
25-
}
8+
test_graph_1 = {0: [1, 2], 1: [0, 3], 2: [0], 3: [1], 4: [5, 6], 5: [4, 6], 6: [4, 5]}
9+
10+
test_graph_2 = {0: [1, 2, 3], 1: [0, 3], 2: [0], 3: [0, 1], 4: [], 5: []}
2611

2712

2813
def dfs(graph: dict, vert: int, visited: list) -> list:

graphs/strongly_connected_components.py

+3-16
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,9 @@
55
66
"""
77

8-
test_graph_1 = {
9-
0: [2, 3],
10-
1: [0],
11-
2: [1],
12-
3: [4],
13-
4: [],
14-
}
15-
16-
test_graph_2 = {
17-
0: [1, 2, 3],
18-
1: [2],
19-
2: [0],
20-
3: [4],
21-
4: [5],
22-
5: [3],
23-
}
8+
test_graph_1 = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}
9+
10+
test_graph_2 = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}
2411

2512

2613
def topology_sort(graph: dict, vert: int, visited: list) -> list:

greedy_method/test_knapsack.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def test_negative_profit_value(self):
3535
# profit = [10, -20, 30, 40, 50, 60]
3636
# weight = [2, 4, 6, 8, 10, 12]
3737
# max_weight = 15
38-
self.assertRaisesRegex(
39-
ValueError, "Weight can not be negative.",
40-
)
38+
self.assertRaisesRegex(ValueError, "Weight can not be negative.")
4139

4240
def test_negative_weight_value(self):
4341
"""

machine_learning/word_frequency_functions.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ def document_frequency(term: str, corpus: str) -> int:
8080
) # strip all punctuation and replace it with ''
8181
docs = corpus_without_punctuation.split("\n")
8282
term = term.lower()
83-
return (
84-
len([doc for doc in docs if term in doc]),
85-
len(docs),
86-
)
83+
return (len([doc for doc in docs if term in doc]), len(docs))
8784

8885

8986
def inverse_document_frequency(df: int, N: int) -> float:

0 commit comments

Comments
 (0)