From 2d3d660155241113b23e4ed810e05479b2fc4bba Mon Sep 17 00:00:00 2001 From: vinayak Date: Thu, 2 Jul 2020 20:02:15 +0530 Subject: [PATCH] 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> --- DIRECTORY.md | 3 ++- ciphers/affine_cipher.py | 2 +- dynamic_programming/minimum_cost_path.py | 4 ++-- graphs/connected_components.py | 19 ++----------------- graphs/strongly_connected_components.py | 17 ++--------------- greedy_method/test_knapsack.py | 4 +--- machine_learning/word_frequency_functions.py | 5 +---- 7 files changed, 11 insertions(+), 43 deletions(-) diff --git a/DIRECTORY.md b/DIRECTORY.md index f35f3906b..f93f082d8 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -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) @@ -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) diff --git a/ciphers/affine_cipher.py b/ciphers/affine_cipher.py index bcf8b6500..5d77cfef3 100644 --- a/ciphers/affine_cipher.py +++ b/ciphers/affine_cipher.py @@ -102,4 +102,4 @@ if __name__ == "__main__": import doctest doctest.testmod() - main() + # main() diff --git a/dynamic_programming/minimum_cost_path.py b/dynamic_programming/minimum_cost_path.py index 93d936656..a8d424eb2 100644 --- a/dynamic_programming/minimum_cost_path.py +++ b/dynamic_programming/minimum_cost_path.py @@ -4,7 +4,7 @@ from typing import List 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 @@ -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])): diff --git a/graphs/connected_components.py b/graphs/connected_components.py index b5ef8c292..6bcc160a9 100644 --- a/graphs/connected_components.py +++ b/graphs/connected_components.py @@ -5,24 +5,9 @@ Finding connected components in graph """ -test_graph_1 = { - 0: [1, 2], - 1: [0, 3], - 2: [0], - 3: [1], - 4: [5, 6], - 5: [4, 6], - 6: [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: [], -} +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: diff --git a/graphs/strongly_connected_components.py b/graphs/strongly_connected_components.py index 283545c9a..d469df0c6 100644 --- a/graphs/strongly_connected_components.py +++ b/graphs/strongly_connected_components.py @@ -5,22 +5,9 @@ Finding strongly connected components in directed graph """ -test_graph_1 = { - 0: [2, 3], - 1: [0], - 2: [1], - 3: [4], - 4: [], -} +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_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: diff --git a/greedy_method/test_knapsack.py b/greedy_method/test_knapsack.py index 9d556d2d2..71a259a1e 100644 --- a/greedy_method/test_knapsack.py +++ b/greedy_method/test_knapsack.py @@ -35,9 +35,7 @@ class TestClass(unittest.TestCase): # 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): """ diff --git a/machine_learning/word_frequency_functions.py b/machine_learning/word_frequency_functions.py index 09c6d269e..e9e9e644b 100644 --- a/machine_learning/word_frequency_functions.py +++ b/machine_learning/word_frequency_functions.py @@ -80,10 +80,7 @@ the third document in the corpus.") ) # 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: