Skip to content

Commit ad91c3a

Browse files
committed
refactor test_get_functions_with_get_chunks (networkx#128)
* clean up test_get_functions_with_get_chunks * change attr to algo for readability * remove module heirarchy * rm set() * added list() * reverting
1 parent 06693ff commit ad91c3a

File tree

2 files changed

+4
-29
lines changed

2 files changed

+4
-29
lines changed

nx_parallel/interface.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
# Approximation
3838
"approximate_all_pairs_node_connectivity",
3939
# Connectivity
40-
"connectivity.all_pairs_node_connectivity",
40+
"all_pairs_node_connectivity",
4141
]
4242

4343

@@ -69,9 +69,7 @@ def __str__(self):
6969
def assign_algorithms(cls):
7070
"""Class decorator to assign algorithms to the class attributes."""
7171
for attr in ALGORITHMS:
72-
# get the function name by parsing the module hierarchy
73-
func_name = attr.rsplit(".", 1)[-1]
74-
setattr(cls, func_name, attrgetter(attr)(algorithms))
72+
setattr(cls, attr, attrgetter(attr)(algorithms))
7573
return cls
7674

7775

nx_parallel/tests/test_get_chunks.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import pytest
1111

1212
import nx_parallel as nxp
13+
from nx_parallel.interface import ALGORITHMS
1314

1415

1516
def get_functions_with_get_chunks(ignore_funcs=[], package_name="nx_parallel"):
@@ -30,31 +31,7 @@ def get_functions_with_get_chunks(ignore_funcs=[], package_name="nx_parallel"):
3031

3132

3233
def test_get_functions_with_get_chunks():
33-
# TODO: Instead of `expected` use ALGORTHMS from interface.py
34-
# take care of functions like `connectivity.all_pairs_node_connectivity`
35-
expected = {
36-
"all_pairs_all_shortest_paths",
37-
"all_pairs_bellman_ford_path",
38-
"all_pairs_bellman_ford_path_length",
39-
"all_pairs_dijkstra",
40-
"all_pairs_dijkstra_path",
41-
"all_pairs_dijkstra_path_length",
42-
"all_pairs_node_connectivity",
43-
"all_pairs_shortest_path",
44-
"all_pairs_shortest_path_length",
45-
"approximate_all_pairs_node_connectivity",
46-
"betweenness_centrality",
47-
"closeness_vitality",
48-
"edge_betweenness_centrality",
49-
"is_reachable",
50-
"johnson",
51-
"local_efficiency",
52-
"node_redundancy",
53-
"number_of_isolates",
54-
"square_clustering",
55-
"tournament_is_strongly_connected",
56-
}
57-
assert set(get_functions_with_get_chunks()) == expected
34+
assert set(get_functions_with_get_chunks()) == set(ALGORITHMS)
5835

5936

6037
ignore_funcs = [

0 commit comments

Comments
 (0)