Skip to content

black fixes and Travis CI fixes #2160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@
* [Max Non Adjacent Sum](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/max_non_adjacent_sum.py)
* [Max Sub Array](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/max_sub_array.py)
* [Max Sum Contiguous Subsequence](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/max_sum_contiguous_subsequence.py)
* [Minimum Cost Path](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/minimum_cost_path.py)
* [Minimum Partition](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/minimum_partition.py)
* [Optimal Binary Search Tree](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/optimal_binary_search_tree.py)
* [Rod Cutting](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/rod_cutting.py)
Expand All @@ -230,11 +231,11 @@
* [Articulation Points](https://github.com/TheAlgorithms/Python/blob/master/graphs/articulation_points.py)
* [Basic Graphs](https://github.com/TheAlgorithms/Python/blob/master/graphs/basic_graphs.py)
* [Bellman Ford](https://github.com/TheAlgorithms/Python/blob/master/graphs/bellman_ford.py)
* [Bfs](https://github.com/TheAlgorithms/Python/blob/master/graphs/bfs.py)
* [Bfs Shortest Path](https://github.com/TheAlgorithms/Python/blob/master/graphs/bfs_shortest_path.py)
* [Bidirectional A Star](https://github.com/TheAlgorithms/Python/blob/master/graphs/bidirectional_a_star.py)
* [Bidirectional Breadth First Search](https://github.com/TheAlgorithms/Python/blob/master/graphs/bidirectional_breadth_first_search.py)
* [Breadth First Search](https://github.com/TheAlgorithms/Python/blob/master/graphs/breadth_first_search.py)
* [Breadth First Search 2](https://github.com/TheAlgorithms/Python/blob/master/graphs/breadth_first_search_2.py)
* [Breadth First Search Shortest Path](https://github.com/TheAlgorithms/Python/blob/master/graphs/breadth_first_search_shortest_path.py)
* [Check Bipartite Graph Bfs](https://github.com/TheAlgorithms/Python/blob/master/graphs/check_bipartite_graph_bfs.py)
* [Check Bipartite Graph Dfs](https://github.com/TheAlgorithms/Python/blob/master/graphs/check_bipartite_graph_dfs.py)
Expand Down
2 changes: 1 addition & 1 deletion ciphers/affine_cipher.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ def get_random_key():
import doctest

doctest.testmod()
main()
# main()
4 changes: 2 additions & 2 deletions dynamic_programming/minimum_cost_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def minimum_cost_path(matrix: List[List[int]]) -> int:
'''
"""
Find the minimum cost traced by all possible paths from top left to bottom right in
a given matrix

Expand All @@ -13,7 +13,7 @@ def minimum_cost_path(matrix: List[List[int]]) -> int:

>>> minimum_cost_path([[2, 1, 4], [2, 1, 3], [3, 2, 1]])
7
'''
"""

# preprocessing the first row
for i in range(1, len(matrix[0])):
Expand Down
21 changes: 3 additions & 18 deletions graphs/connected_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,9 @@

"""

test_graph_1 = {
0: [1, 2],
1: [0, 3],
2: [0],
3: [1],
4: [5, 6],
5: [4, 6],
6: [4, 5],
}

test_graph_2 = {
0: [1, 2, 3],
1: [0, 3],
2: [0],
3: [0, 1],
4: [],
5: [],
}
test_graph_1 = {0: [1, 2], 1: [0, 3], 2: [0], 3: [1], 4: [5, 6], 5: [4, 6], 6: [4, 5]}

test_graph_2 = {0: [1, 2, 3], 1: [0, 3], 2: [0], 3: [0, 1], 4: [], 5: []}


def dfs(graph: dict, vert: int, visited: list) -> list:
Expand Down
19 changes: 3 additions & 16 deletions graphs/strongly_connected_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,9 @@

"""

test_graph_1 = {
0: [2, 3],
1: [0],
2: [1],
3: [4],
4: [],
}

test_graph_2 = {
0: [1, 2, 3],
1: [2],
2: [0],
3: [4],
4: [5],
5: [3],
}
test_graph_1 = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

test_graph_2 = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}


def topology_sort(graph: dict, vert: int, visited: list) -> list:
Expand Down
4 changes: 1 addition & 3 deletions greedy_method/test_knapsack.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ def test_negative_profit_value(self):
# profit = [10, -20, 30, 40, 50, 60]
# weight = [2, 4, 6, 8, 10, 12]
# max_weight = 15
self.assertRaisesRegex(
ValueError, "Weight can not be negative.",
)
self.assertRaisesRegex(ValueError, "Weight can not be negative.")

def test_negative_weight_value(self):
"""
Expand Down
5 changes: 1 addition & 4 deletions machine_learning/word_frequency_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ def document_frequency(term: str, corpus: str) -> int:
) # strip all punctuation and replace it with ''
docs = corpus_without_punctuation.split("\n")
term = term.lower()
return (
len([doc for doc in docs if term in doc]),
len(docs),
)
return (len([doc for doc in docs if term in doc]), len(docs))


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