Skip to content
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

Fix long line, tests #2123

Merged
merged 8 commits into from
Jun 16, 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
1 change: 1 addition & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion digital_image_processing/resize/resize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions divide_and_conquer/convex_hull.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

"""
Expand Down
3 changes: 2 additions & 1 deletion maths/gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
19 changes: 14 additions & 5 deletions searches/tabu_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,19 @@ 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']],
... '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 = []
Expand Down Expand Up @@ -209,7 +218,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):

Expand Down