black fixes and Travis CI fixes (#2160)

* black format

* updating DIRECTORY.md

* fixes

* fixup! Format Python code with psf/black push

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
vinayak 2020-07-02 20:02:15 +05:30 committed by GitHub
parent c534e77cb1
commit 2d3d660155
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 43 deletions

View File

@ -205,6 +205,7 @@
* [Max Non Adjacent Sum](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/max_non_adjacent_sum.py) * [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 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) * [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) * [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) * [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) * [Rod Cutting](https://github.com/TheAlgorithms/Python/blob/master/dynamic_programming/rod_cutting.py)
@ -230,11 +231,11 @@
* [Articulation Points](https://github.com/TheAlgorithms/Python/blob/master/graphs/articulation_points.py) * [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) * [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) * [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) * [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 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) * [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](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) * [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 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) * [Check Bipartite Graph Dfs](https://github.com/TheAlgorithms/Python/blob/master/graphs/check_bipartite_graph_dfs.py)

View File

@ -102,4 +102,4 @@ if __name__ == "__main__":
import doctest import doctest
doctest.testmod() doctest.testmod()
main() # main()

View File

@ -4,7 +4,7 @@ from typing import List
def minimum_cost_path(matrix: List[List[int]]) -> int: 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 Find the minimum cost traced by all possible paths from top left to bottom right in
a given matrix a given matrix
@ -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]]) >>> minimum_cost_path([[2, 1, 4], [2, 1, 3], [3, 2, 1]])
7 7
''' """
# preprocessing the first row # preprocessing the first row
for i in range(1, len(matrix[0])): for i in range(1, len(matrix[0])):

View File

@ -5,24 +5,9 @@ Finding connected components in graph
""" """
test_graph_1 = { test_graph_1 = {0: [1, 2], 1: [0, 3], 2: [0], 3: [1], 4: [5, 6], 5: [4, 6], 6: [4, 5]}
0: [1, 2],
1: [0, 3],
2: [0],
3: [1],
4: [5, 6],
5: [4, 6],
6: [4, 5],
}
test_graph_2 = { test_graph_2 = {0: [1, 2, 3], 1: [0, 3], 2: [0], 3: [0, 1], 4: [], 5: []}
0: [1, 2, 3],
1: [0, 3],
2: [0],
3: [0, 1],
4: [],
5: [],
}
def dfs(graph: dict, vert: int, visited: list) -> list: def dfs(graph: dict, vert: int, visited: list) -> list:

View File

@ -5,22 +5,9 @@ Finding strongly connected components in directed graph
""" """
test_graph_1 = { test_graph_1 = {0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}
0: [2, 3],
1: [0],
2: [1],
3: [4],
4: [],
}
test_graph_2 = { test_graph_2 = {0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}
0: [1, 2, 3],
1: [2],
2: [0],
3: [4],
4: [5],
5: [3],
}
def topology_sort(graph: dict, vert: int, visited: list) -> list: def topology_sort(graph: dict, vert: int, visited: list) -> list:

View File

@ -35,9 +35,7 @@ class TestClass(unittest.TestCase):
# profit = [10, -20, 30, 40, 50, 60] # profit = [10, -20, 30, 40, 50, 60]
# weight = [2, 4, 6, 8, 10, 12] # weight = [2, 4, 6, 8, 10, 12]
# max_weight = 15 # max_weight = 15
self.assertRaisesRegex( self.assertRaisesRegex(ValueError, "Weight can not be negative.")
ValueError, "Weight can not be negative.",
)
def test_negative_weight_value(self): def test_negative_weight_value(self):
""" """

View File

@ -80,10 +80,7 @@ the third document in the corpus.")
) # strip all punctuation and replace it with '' ) # strip all punctuation and replace it with ''
docs = corpus_without_punctuation.split("\n") docs = corpus_without_punctuation.split("\n")
term = term.lower() term = term.lower()
return ( return (len([doc for doc in docs if term in doc]), len(docs))
len([doc for doc in docs if term in doc]),
len(docs),
)
def inverse_document_frequency(df: int, N: int) -> float: def inverse_document_frequency(df: int, N: int) -> float: