From 7793f4189e4264c319fb6dbe77346d3d8fef54c9 Mon Sep 17 00:00:00 2001 From: Meysam Azad Date: Fri, 1 Oct 2021 23:07:45 +0300 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20type=20annotations=20for=20pypi=20?= =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4052 --- graphs/boruvka.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/graphs/boruvka.py b/graphs/boruvka.py index 3fa5c6fd2a26..d7148011f28a 100644 --- a/graphs/boruvka.py +++ b/graphs/boruvka.py @@ -24,6 +24,7 @@ Details: https://en.wikipedia.org/wiki/Bor%C5%AFvka%27s_algorithm """ +import typing class Graph: @@ -39,8 +40,8 @@ def __init__(self, num_of_nodes: int) -> None: """ self.m_num_of_nodes = num_of_nodes - self.m_edges = [] - self.m_component = {} + self.m_edges: typing.List[typing.List[int]] = [] + self.m_component: typing.Dict[int, int] = {} def add_edge(self, u_node: int, v_node: int, weight: int) -> None: """Adds an edge in the format [first, second, edge weight] to graph.""" @@ -83,7 +84,7 @@ def boruvka(self) -> None: component_size = [] mst_weight = 0 - minimum_weight_edge = [-1] * self.m_num_of_nodes + minimum_weight_edge: typing.List[typing.Any] = [-1] * self.m_num_of_nodes # A list of components (initialized to all of the nodes) for node in range(self.m_num_of_nodes): From fc19139432318d5bb4d420df98878bf82e560fff Mon Sep 17 00:00:00 2001 From: github-actions <${GITHUB_ACTOR}@users.noreply.github.com> Date: Fri, 1 Oct 2021 20:12:55 +0000 Subject: [PATCH 2/3] updating DIRECTORY.md --- DIRECTORY.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DIRECTORY.md b/DIRECTORY.md index 2e9942b5bf93..505ae0a26930 100644 --- a/DIRECTORY.md +++ b/DIRECTORY.md @@ -274,6 +274,7 @@ * [Test Send File](https://github.com/TheAlgorithms/Python/blob/master/file_transfer/tests/test_send_file.py) ## Fractals + * [Julia Sets](https://github.com/TheAlgorithms/Python/blob/master/fractals/julia_sets.py) * [Koch Snowflake](https://github.com/TheAlgorithms/Python/blob/master/fractals/koch_snowflake.py) * [Mandelbrot](https://github.com/TheAlgorithms/Python/blob/master/fractals/mandelbrot.py) * [Sierpinski Triangle](https://github.com/TheAlgorithms/Python/blob/master/fractals/sierpinski_triangle.py) @@ -424,10 +425,12 @@ * [Binomial Distribution](https://github.com/TheAlgorithms/Python/blob/master/maths/binomial_distribution.py) * [Bisection](https://github.com/TheAlgorithms/Python/blob/master/maths/bisection.py) * [Ceil](https://github.com/TheAlgorithms/Python/blob/master/maths/ceil.py) + * [Check Polygon](https://github.com/TheAlgorithms/Python/blob/master/maths/check_polygon.py) * [Chudnovsky Algorithm](https://github.com/TheAlgorithms/Python/blob/master/maths/chudnovsky_algorithm.py) * [Collatz Sequence](https://github.com/TheAlgorithms/Python/blob/master/maths/collatz_sequence.py) * [Combinations](https://github.com/TheAlgorithms/Python/blob/master/maths/combinations.py) * [Decimal Isolate](https://github.com/TheAlgorithms/Python/blob/master/maths/decimal_isolate.py) + * [Double Factorial Iterative](https://github.com/TheAlgorithms/Python/blob/master/maths/double_factorial_iterative.py) * [Double Factorial Recursive](https://github.com/TheAlgorithms/Python/blob/master/maths/double_factorial_recursive.py) * [Entropy](https://github.com/TheAlgorithms/Python/blob/master/maths/entropy.py) * [Euclidean Distance](https://github.com/TheAlgorithms/Python/blob/master/maths/euclidean_distance.py) From 54bc9ef93ce2c29055eb6ee2ed5ab353b4cde155 Mon Sep 17 00:00:00 2001 From: Meysam Date: Sun, 17 Oct 2021 19:13:20 +0300 Subject: [PATCH 3/3] apply suggestions from code review Co-authored-by: Christian Clauss --- graphs/boruvka.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/graphs/boruvka.py b/graphs/boruvka.py index d7148011f28a..eea0b0009941 100644 --- a/graphs/boruvka.py +++ b/graphs/boruvka.py @@ -24,7 +24,7 @@ Details: https://en.wikipedia.org/wiki/Bor%C5%AFvka%27s_algorithm """ -import typing +from __future__ import annotations class Graph: @@ -40,8 +40,8 @@ def __init__(self, num_of_nodes: int) -> None: """ self.m_num_of_nodes = num_of_nodes - self.m_edges: typing.List[typing.List[int]] = [] - self.m_component: typing.Dict[int, int] = {} + self.m_edges: list[list[int]] = [] + self.m_component: dict[int, int] = {} def add_edge(self, u_node: int, v_node: int, weight: int) -> None: """Adds an edge in the format [first, second, edge weight] to graph.""" @@ -84,7 +84,7 @@ def boruvka(self) -> None: component_size = [] mst_weight = 0 - minimum_weight_edge: typing.List[typing.Any] = [-1] * self.m_num_of_nodes + minimum_weight_edge: list[int] = [-1] * self.m_num_of_nodes # A list of components (initialized to all of the nodes) for node in range(self.m_num_of_nodes):