From cfdcea066a2f370d943e1b46592a7b09e26f4abd Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 16 Jun 2020 11:52:47 +0200 Subject: [PATCH 1/8] Fix long line --- maths/gamma.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maths/gamma.py b/maths/gamma.py index febbee9a5888..9193929baa28 100644 --- a/maths/gamma.py +++ b/maths/gamma.py @@ -29,7 +29,8 @@ def gamma(num: float) -> float: 40320.0 >>> from math import gamma as math_gamma - >>> all(gamma(i)/math_gamma(i) <= 1.000000001 and abs(gamma(i)/math_gamma(i)) > .99999999 for i in range(1, 50)) + >>> all(.99999999 < gamma(i) / math_gamma(i) <= 1.000000001 + ... for i in range(1, 50)) True From a7b05c69d7406b8faf4a2ed08f379a1aa9137c65 Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Tue, 16 Jun 2020 09:53:23 +0000 Subject: [PATCH 2/8] updating DIRECTORY.md --- DIRECTORY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 5f9046cc7108..b34658b32065 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -18,6 +18,7 @@ * [Hamiltonian Cycle](https://github.com/TheAlgorithms/Python/blob/master/backtracking/hamiltonian_cycle.py) * [Minimax](https://github.com/TheAlgorithms/Python/blob/master/backtracking/minimax.py) * [N Queens](https://github.com/TheAlgorithms/Python/blob/master/backtracking/n_queens.py) + * [Rat In Maze](https://github.com/TheAlgorithms/Python/blob/master/backtracking/rat_in_maze.py) * [Sudoku](https://github.com/TheAlgorithms/Python/blob/master/backtracking/sudoku.py) * [Sum Of Subsets](https://github.com/TheAlgorithms/Python/blob/master/backtracking/sum_of_subsets.py) From 60b20c4589074c356058a38306a6b6eb2debface Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 16 Jun 2020 13:21:41 +0200 Subject: [PATCH 3/8] Add doctest --- searches/tabu_search.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/searches/tabu_search.py b/searches/tabu_search.py index cc4c95ead615..e4f6f0b66682 100644 --- a/searches/tabu_search.py +++ b/searches/tabu_search.py @@ -143,6 +143,19 @@ def find_neighborhood(solution, dict_of_neighbours): [['a','e','b','d','c','a',90], [['a','c','d','b','e','a',90], ['a','d','b','c','e','a',93], ['a','c','b','e','d','a',102], ['a','c','e','d','b','a',113], ['a','b','c','d','e','a',93]] + >>> find_neighborhood(['a', 'c', 'b', 'd', 'e', 'a'], + ... {'a': [['b', '20'], ['c', '18'], ['d', '22'], ['e', '26']], + ... 'c': [['a', '18'], ['b', '10'], ['d', '23'], ['e', '24']], + ... 'b': [['a', '20'], ['c', '10'], ['d', '11'], ['e', '12']], + ... 'e': [['a', '26'], ['b', '12'], ['c', '24'], ['d', '40']], + ... 'd': [['a', '22'], ['b', '11'], ['c', '23'], ['e', '40']]} + ... ) # doctest: +NORMALIZE_WHITESPACE + [['a', 'e', 'b', 'd', 'c', 'a', 90], + ['a', 'c', 'd', 'b', 'e', 'a', 90], + ['a', 'd', 'b', 'c', 'e', 'a', 93], + ['a', 'c', 'b', 'e', 'd', 'a', 102], + ['a', 'c', 'e', 'd', 'b', 'a', 113], + ['a', 'b', 'c', 'd', 'e', 'a', 119]] """ neighborhood_of_solution = [] @@ -209,7 +222,7 @@ def tabu_search( best_cost_index = len(best_solution) - 1 found = False - while found is False: + while not found: i = 0 while i < len(best_solution): From 503f1ba8722b2d0723d13e1893913c06c041b65f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 16 Jun 2020 13:28:27 +0200 Subject: [PATCH 4/8] ... --- divide_and_conquer/convex_hull.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/divide_and_conquer/convex_hull.py b/divide_and_conquer/convex_hull.py index de67cb1e06df..cf2c7f835798 100644 --- a/divide_and_conquer/convex_hull.py +++ b/divide_and_conquer/convex_hull.py @@ -325,10 +325,10 @@ def convex_hull_recursive(points): >>> convex_hull_recursive([[0, 0], [1, 0], [10, 0]]) [(0.0, 0.0), (10.0, 0.0)] >>> convex_hull_recursive([[-1, 1],[-1, -1], [0, 0], [0.5, 0.5], [1, -1], [1, 1], - [-0.75, 1]]) + ... [-0.75, 1]]) [(-1.0, -1.0), (-1.0, 1.0), (1.0, -1.0), (1.0, 1.0)] >>> convex_hull_recursive([(0, 3), (2, 2), (1, 1), (2, 1), (3, 0), (0, 0), (3, 3), - (2, -1), (2, -4), (1, -3)]) + ... (2, -1), (2, -4), (1, -3)]) [(0.0, 0.0), (0.0, 3.0), (1.0, -3.0), (2.0, -4.0), (3.0, 0.0), (3.0, 3.0)] """ From cb46604ba2fa41fba9ad1ba797f8876806865960 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 16 Jun 2020 13:32:23 +0200 Subject: [PATCH 5/8] ... --- digital_image_processing/resize/resize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/digital_image_processing/resize/resize.py b/digital_image_processing/resize/resize.py index afcacda4bd86..f33e80e580de 100644 --- a/digital_image_processing/resize/resize.py +++ b/digital_image_processing/resize/resize.py @@ -50,7 +50,7 @@ def get_y(self, y: int) -> int: :param y: Destination X coordinate :return: Parent X coordinate based on `y ratio` >>> nn = NearestNeighbour(imread("digital_image_processing/image_data/lena.jpg", - 1), 100, 100) + ... 1), 100, 100) >>> nn.ratio_y = 0.5 >>> nn.get_y(4) 2 From a1b986e4e09332adcd723737d8c91fe27eabf28e Mon Sep 17 00:00:00 2001 From: John Law Date: Tue, 16 Jun 2020 19:33:22 +0800 Subject: [PATCH 6/8] Update tabu_search.py --- searches/tabu_search.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/searches/tabu_search.py b/searches/tabu_search.py index e4f6f0b66682..cedcffe02374 100644 --- a/searches/tabu_search.py +++ b/searches/tabu_search.py @@ -144,12 +144,12 @@ def find_neighborhood(solution, dict_of_neighbours): ['a','d','b','c','e','a',93], ['a','c','b','e','d','a',102], ['a','c','e','d','b','a',113], ['a','b','c','d','e','a',93]] >>> find_neighborhood(['a', 'c', 'b', 'd', 'e', 'a'], - ... {'a': [['b', '20'], ['c', '18'], ['d', '22'], ['e', '26']], - ... 'c': [['a', '18'], ['b', '10'], ['d', '23'], ['e', '24']], - ... 'b': [['a', '20'], ['c', '10'], ['d', '11'], ['e', '12']], - ... 'e': [['a', '26'], ['b', '12'], ['c', '24'], ['d', '40']], - ... 'd': [['a', '22'], ['b', '11'], ['c', '23'], ['e', '40']]} - ... ) # doctest: +NORMALIZE_WHITESPACE + ... {'a': [['b', '20'], ['c', '18'], ['d', '22'], ['e', '26']], + ... 'c': [['a', '18'], ['b', '10'], ['d', '23'], ['e', '24']], + ... 'b': [['a', '20'], ['c', '10'], ['d', '11'], ['e', '12']], + ... 'e': [['a', '26'], ['b', '12'], ['c', '24'], ['d', '40']], + ... 'd': [['a', '22'], ['b', '11'], ['c', '23'], ['e', '40']]} + ... ) # doctest: +NORMALIZE_WHITESPACE [['a', 'e', 'b', 'd', 'c', 'a', 90], ['a', 'c', 'd', 'b', 'e', 'a', 90], ['a', 'd', 'b', 'c', 'e', 'a', 93], From abaa2479206aa0d08417b8b8757a215937f5470c Mon Sep 17 00:00:00 2001 From: John Law Date: Tue, 16 Jun 2020 19:38:35 +0800 Subject: [PATCH 7/8] space --- searches/tabu_search.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/searches/tabu_search.py b/searches/tabu_search.py index cedcffe02374..8a4eed02fa12 100644 --- a/searches/tabu_search.py +++ b/searches/tabu_search.py @@ -144,12 +144,12 @@ def find_neighborhood(solution, dict_of_neighbours): ['a','d','b','c','e','a',93], ['a','c','b','e','d','a',102], ['a','c','e','d','b','a',113], ['a','b','c','d','e','a',93]] >>> find_neighborhood(['a', 'c', 'b', 'd', 'e', 'a'], - ... {'a': [['b', '20'], ['c', '18'], ['d', '22'], ['e', '26']], - ... 'c': [['a', '18'], ['b', '10'], ['d', '23'], ['e', '24']], - ... 'b': [['a', '20'], ['c', '10'], ['d', '11'], ['e', '12']], - ... 'e': [['a', '26'], ['b', '12'], ['c', '24'], ['d', '40']], - ... 'd': [['a', '22'], ['b', '11'], ['c', '23'], ['e', '40']]} - ... ) # doctest: +NORMALIZE_WHITESPACE + ... {'a': [['b', '20'], ['c', '18'], ['d', '22'], ['e', '26']], + ... 'c': [['a', '18'], ['b', '10'], ['d', '23'], ['e', '24']], + ... 'b': [['a', '20'], ['c', '10'], ['d', '11'], ['e', '12']], + ... 'e': [['a', '26'], ['b', '12'], ['c', '24'], ['d', '40']], + ... 'd': [['a', '22'], ['b', '11'], ['c', '23'], ['e', '40']]} + ... ) # doctest: +NORMALIZE_WHITESPACE [['a', 'e', 'b', 'd', 'c', 'a', 90], ['a', 'c', 'd', 'b', 'e', 'a', 90], ['a', 'd', 'b', 'c', 'e', 'a', 93], From 33c4eed44fe033d0c9ee907e3d148c5787533355 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 16 Jun 2020 14:06:34 +0200 Subject: [PATCH 8/8] Fix doctest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit >>> find_neighborhood(['a','c','b','d','e','a']) # doctest: +NORMALIZE_WHITESPACE [['a','e','b','d','c','a',90], [['a','c','d','b','e','a',90], ['a','d','b','c','e','a',93], ['a','c','b','e','d','a',102], ['a','c','e','d','b','a',113], ['a','b','c','d','e','a',93]] --- searches/tabu_search.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/searches/tabu_search.py b/searches/tabu_search.py index 8a4eed02fa12..f0c3241dbe19 100644 --- a/searches/tabu_search.py +++ b/searches/tabu_search.py @@ -139,10 +139,6 @@ def find_neighborhood(solution, dict_of_neighbours): from the solution that the method took as an input Example: - >>> find_neighborhood(['a','c','b','d','e','a']) # doctest: +NORMALIZE_WHITESPACE - [['a','e','b','d','c','a',90], [['a','c','d','b','e','a',90], - ['a','d','b','c','e','a',93], ['a','c','b','e','d','a',102], - ['a','c','e','d','b','a',113], ['a','b','c','d','e','a',93]] >>> find_neighborhood(['a', 'c', 'b', 'd', 'e', 'a'], ... {'a': [['b', '20'], ['c', '18'], ['d', '22'], ['e', '26']], ... 'c': [['a', '18'], ['b', '10'], ['d', '23'], ['e', '24']],