From ea1a34f81b1e13e54a67191a5b798dae85827d04 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Oct 2021 15:24:17 +0200 Subject: [PATCH 01/10] mandelbrot.py: Commenting out long running tests --- fractals/mandelbrot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fractals/mandelbrot.py b/fractals/mandelbrot.py index de795bb3fc6f..5d61b72e172f 100644 --- a/fractals/mandelbrot.py +++ b/fractals/mandelbrot.py @@ -101,9 +101,11 @@ def get_image( of the Mandelbrot set is viewed. The main area of the Mandelbrot set is roughly between "-1.5 < x < 0.5" and "-1 < y < 1" in the figure-coordinates. - >>> get_image().load()[0,0] + Commenting out tests that slow down pytest... + # 13.35s call fractals/mandelbrot.py::mandelbrot.get_image + # >>> get_image().load()[0,0] (255, 0, 0) - >>> get_image(use_distance_color_coding = False).load()[0,0] + # >>> get_image(use_distance_color_coding = False).load()[0,0] (255, 255, 255) """ img = Image.new("RGB", (image_width, image_height)) From 496315603758c2188ea655cf02900dc53ade0b5e Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Sat, 23 Oct 2021 13:24:35 +0000 Subject: [PATCH 02/10] updating DIRECTORY.md --- DIRECTORY.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 950d8e2c0c4b..66d5f8040951 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -317,6 +317,7 @@ * [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) + * [Check Cycle](https://github.com/TheAlgorithms/Python/blob/master/graphs/check_cycle.py) * [Connected Components](https://github.com/TheAlgorithms/Python/blob/master/graphs/connected_components.py) * [Depth First Search](https://github.com/TheAlgorithms/Python/blob/master/graphs/depth_first_search.py) * [Depth First Search 2](https://github.com/TheAlgorithms/Python/blob/master/graphs/depth_first_search_2.py) @@ -370,6 +371,7 @@ * [Md5](https://github.com/TheAlgorithms/Python/blob/master/hashes/md5.py) * [Sdbm](https://github.com/TheAlgorithms/Python/blob/master/hashes/sdbm.py) * [Sha1](https://github.com/TheAlgorithms/Python/blob/master/hashes/sha1.py) + * [Sha256](https://github.com/TheAlgorithms/Python/blob/master/hashes/sha256.py) ## Knapsack * [Greedy Knapsack](https://github.com/TheAlgorithms/Python/blob/master/knapsack/greedy_knapsack.py) @@ -979,6 +981,7 @@ * [Instagram Crawler](https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_crawler.py) * [Instagram Pic](https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_pic.py) * [Instagram Video](https://github.com/TheAlgorithms/Python/blob/master/web_programming/instagram_video.py) + * [Nasa Data](https://github.com/TheAlgorithms/Python/blob/master/web_programming/nasa_data.py) * [Random Anime Character](https://github.com/TheAlgorithms/Python/blob/master/web_programming/random_anime_character.py) * [Recaptcha Verification](https://github.com/TheAlgorithms/Python/blob/master/web_programming/recaptcha_verification.py) * [Slack Message](https://github.com/TheAlgorithms/Python/blob/master/web_programming/slack_message.py) From 0e344de2515193fc290e866464c2d811b3b67815 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Oct 2021 16:41:25 +0200 Subject: [PATCH 03/10] Comment out 9 sec doctests --- graphs/bidirectional_breadth_first_search.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/graphs/bidirectional_breadth_first_search.py b/graphs/bidirectional_breadth_first_search.py index 27e4f0b16bbf..d3605445ef0f 100644 --- a/graphs/bidirectional_breadth_first_search.py +++ b/graphs/bidirectional_breadth_first_search.py @@ -106,14 +106,16 @@ def retrace_path(self, node: Node | None) -> Path: class BidirectionalBreadthFirstSearch: """ - >>> bd_bfs = BidirectionalBreadthFirstSearch((0, 0), (len(grid) - 1, + # Comment out slow pytests... + # 9.15s call graphs/bidirectional_breadth_first_search.py::graphs.bidirectional_breadth_first_search.BreadthFirstSearch + # >>> bd_bfs = BidirectionalBreadthFirstSearch((0, 0), (len(grid) - 1, ... len(grid[0]) - 1)) - >>> bd_bfs.fwd_bfs.start.pos == bd_bfs.bwd_bfs.target.pos + # >>> bd_bfs.fwd_bfs.start.pos == bd_bfs.bwd_bfs.target.pos True - >>> bd_bfs.retrace_bidirectional_path(bd_bfs.fwd_bfs.start, + # >>> bd_bfs.retrace_bidirectional_path(bd_bfs.fwd_bfs.start, ... bd_bfs.bwd_bfs.start) [(0, 0)] - >>> bd_bfs.search() # doctest: +NORMALIZE_WHITESPACE + # >>> bd_bfs.search() # doctest: +NORMALIZE_WHITESPACE [(0, 0), (0, 1), (0, 2), (1, 2), (2, 2), (2, 3), (2, 4), (3, 4), (3, 5), (3, 6), (4, 6), (5, 6), (6, 6)] """ From 8c6b8856bf21c325334f0cd9e5d26149fb156606 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Oct 2021 16:48:56 +0200 Subject: [PATCH 04/10] Update bidirectional_breadth_first_search.py --- graphs/bidirectional_breadth_first_search.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/graphs/bidirectional_breadth_first_search.py b/graphs/bidirectional_breadth_first_search.py index d3605445ef0f..6a2a62ce39ef 100644 --- a/graphs/bidirectional_breadth_first_search.py +++ b/graphs/bidirectional_breadth_first_search.py @@ -107,7 +107,8 @@ def retrace_path(self, node: Node | None) -> Path: class BidirectionalBreadthFirstSearch: """ # Comment out slow pytests... - # 9.15s call graphs/bidirectional_breadth_first_search.py::graphs.bidirectional_breadth_first_search.BreadthFirstSearch + # 9.15s call graphs/bidirectional_breadth_first_search.py:: \ + # graphs.bidirectional_breadth_first_search.BreadthFirstSearch # >>> bd_bfs = BidirectionalBreadthFirstSearch((0, 0), (len(grid) - 1, ... len(grid[0]) - 1)) # >>> bd_bfs.fwd_bfs.start.pos == bd_bfs.bwd_bfs.target.pos From c1950ddf1533d99b3450af12f46e68dfc0aab240 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Oct 2021 17:01:02 +0200 Subject: [PATCH 05/10] Comment out slow tests --- graphs/bidirectional_breadth_first_search.py | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/graphs/bidirectional_breadth_first_search.py b/graphs/bidirectional_breadth_first_search.py index 6a2a62ce39ef..cf0f92fe4a4c 100644 --- a/graphs/bidirectional_breadth_first_search.py +++ b/graphs/bidirectional_breadth_first_search.py @@ -34,16 +34,19 @@ def __init__( class BreadthFirstSearch: """ - >>> bfs = BreadthFirstSearch((0, 0), (len(grid) - 1, len(grid[0]) - 1)) - >>> (bfs.start.pos_y + delta[3][0], bfs.start.pos_x + delta[3][1]) + # Comment out slow pytests... + # 9.15s call graphs/bidirectional_breadth_first_search.py:: \ + # graphs.bidirectional_breadth_first_search.BreadthFirstSearch + # >>> bfs = BreadthFirstSearch((0, 0), (len(grid) - 1, len(grid[0]) - 1)) + # >>> (bfs.start.pos_y + delta[3][0], bfs.start.pos_x + delta[3][1]) (0, 1) - >>> [x.pos for x in bfs.get_successors(bfs.start)] + # >>> [x.pos for x in bfs.get_successors(bfs.start)] [(1, 0), (0, 1)] - >>> (bfs.start.pos_y + delta[2][0], bfs.start.pos_x + delta[2][1]) + # >>> (bfs.start.pos_y + delta[2][0], bfs.start.pos_x + delta[2][1]) (1, 0) - >>> bfs.retrace_path(bfs.start) + # >>> bfs.retrace_path(bfs.start) [(0, 0)] - >>> bfs.search() # doctest: +NORMALIZE_WHITESPACE + # >>> bfs.search() # doctest: +NORMALIZE_WHITESPACE [(0, 0), (1, 0), (2, 0), (3, 0), (3, 1), (4, 1), (5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (6, 5), (6, 6)] """ @@ -106,17 +109,14 @@ def retrace_path(self, node: Node | None) -> Path: class BidirectionalBreadthFirstSearch: """ - # Comment out slow pytests... - # 9.15s call graphs/bidirectional_breadth_first_search.py:: \ - # graphs.bidirectional_breadth_first_search.BreadthFirstSearch - # >>> bd_bfs = BidirectionalBreadthFirstSearch((0, 0), (len(grid) - 1, + >>> bd_bfs = BidirectionalBreadthFirstSearch((0, 0), (len(grid) - 1, ... len(grid[0]) - 1)) - # >>> bd_bfs.fwd_bfs.start.pos == bd_bfs.bwd_bfs.target.pos + >>> bd_bfs.fwd_bfs.start.pos == bd_bfs.bwd_bfs.target.pos True - # >>> bd_bfs.retrace_bidirectional_path(bd_bfs.fwd_bfs.start, + >>> bd_bfs.retrace_bidirectional_path(bd_bfs.fwd_bfs.start, ... bd_bfs.bwd_bfs.start) [(0, 0)] - # >>> bd_bfs.search() # doctest: +NORMALIZE_WHITESPACE + >>> bd_bfs.search() # doctest: +NORMALIZE_WHITESPACE [(0, 0), (0, 1), (0, 2), (1, 2), (2, 2), (2, 3), (2, 4), (3, 4), (3, 5), (3, 6), (4, 6), (5, 6), (6, 6)] """ From 3e8f0fd62723978284e38251f3bc62709942e4cb Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Oct 2021 17:33:06 +0200 Subject: [PATCH 06/10] Comment out slow (9.15 sec) pytests... --- graphs/bidirectional_breadth_first_search.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphs/bidirectional_breadth_first_search.py b/graphs/bidirectional_breadth_first_search.py index cf0f92fe4a4c..511b080a9add 100644 --- a/graphs/bidirectional_breadth_first_search.py +++ b/graphs/bidirectional_breadth_first_search.py @@ -36,7 +36,7 @@ class BreadthFirstSearch: """ # Comment out slow pytests... # 9.15s call graphs/bidirectional_breadth_first_search.py:: \ - # graphs.bidirectional_breadth_first_search.BreadthFirstSearch + # graphs.bidirectional_breadth_first_search.BreadthFirstSearch # >>> bfs = BreadthFirstSearch((0, 0), (len(grid) - 1, len(grid[0]) - 1)) # >>> (bfs.start.pos_y + delta[3][0], bfs.start.pos_x + delta[3][1]) (0, 1) From b620dee844252e393daa1db98614e9a2cd41faf7 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Oct 2021 17:47:32 +0200 Subject: [PATCH 07/10] # Comment out slow (4.20s call) doctests --- web_programming/download_images_from_google_query.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web_programming/download_images_from_google_query.py b/web_programming/download_images_from_google_query.py index c26262788c4c..b11a7f883085 100644 --- a/web_programming/download_images_from_google_query.py +++ b/web_programming/download_images_from_google_query.py @@ -24,9 +24,10 @@ def download_images_from_google_query(query: str = "dhaka", max_images: int = 5) Returns: The number of images successfully downloaded. - >>> download_images_from_google_query() + # Comment out slow (4.20s call) doctests + # >>> download_images_from_google_query() 5 - >>> download_images_from_google_query("potato") + # >>> download_images_from_google_query("potato") 5 """ max_images = min(max_images, 50) # Prevent abuse! From bdcbac7926113921d058c12a4d5a5e3d895a8c33 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Oct 2021 17:54:13 +0200 Subject: [PATCH 08/10] Comment out slow (3.45s) doctests --- maths/miller_rabin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maths/miller_rabin.py b/maths/miller_rabin.py index fe992027190b..dbd2cf09f3c6 100644 --- a/maths/miller_rabin.py +++ b/maths/miller_rabin.py @@ -9,7 +9,8 @@ def is_prime(n, prec=1000): """ >>> from .prime_check import prime_check - >>> all(is_prime(i) == prime_check(i) for i in range(1000)) + # >>> all(is_prime(i) == prime_check(i) for i in range(1000)) # 3.45s + >>> all(is_prime(i) == prime_check(i) for i in range(500)) True """ if n < 2: From 03e700eebf12ad95d2a59e3a6576c99d2190fa13 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Oct 2021 18:05:41 +0200 Subject: [PATCH 09/10] Update miller_rabin.py --- maths/miller_rabin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/miller_rabin.py b/maths/miller_rabin.py index dbd2cf09f3c6..8f6ebdbaf328 100644 --- a/maths/miller_rabin.py +++ b/maths/miller_rabin.py @@ -9,7 +9,7 @@ def is_prime(n, prec=1000): """ >>> from .prime_check import prime_check - # >>> all(is_prime(i) == prime_check(i) for i in range(1000)) # 3.45s + >>> # all(is_prime(i) == prime_check(i) for i in range(1000)) # 3.45s >>> all(is_prime(i) == prime_check(i) for i in range(500)) True """ From 0b4f9601fc35163603deb4e03bc5fa2cf6eacea6 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 23 Oct 2021 18:11:44 +0200 Subject: [PATCH 10/10] Update miller_rabin.py --- maths/miller_rabin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/miller_rabin.py b/maths/miller_rabin.py index 8f6ebdbaf328..2b0944508b4b 100644 --- a/maths/miller_rabin.py +++ b/maths/miller_rabin.py @@ -10,7 +10,7 @@ def is_prime(n, prec=1000): """ >>> from .prime_check import prime_check >>> # all(is_prime(i) == prime_check(i) for i in range(1000)) # 3.45s - >>> all(is_prime(i) == prime_check(i) for i in range(500)) + >>> all(is_prime(i) == prime_check(i) for i in range(256)) True """ if n < 2: