Skip to content

Commit 20e2aac

Browse files
authored
Move files around to match NetworkX file and directory structure (#7)
1 parent 00e4217 commit 20e2aac

File tree

14 files changed

+43
-40
lines changed

14 files changed

+43
-40
lines changed

graphblas_algorithms/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
from . import _version
2-
from .cluster import average_clustering, clustering, transitivity, triangles # noqa
3-
from .link_analysis import pagerank # noqa
4-
from .reciprocity import overall_reciprocity, reciprocity # noqa
2+
from .algorithms import *
53

64
__version__ = _version.get_versions()["version"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .cluster import average_clustering, clustering, transitivity, triangles
2+
from .link_analysis import pagerank
3+
from .reciprocity import overall_reciprocity, reciprocity

graphblas_algorithms/cluster.py renamed to graphblas_algorithms/algorithms/cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from networkx import clustering as _nx_clustering
77
from networkx.utils import not_implemented_for
88

9-
from ._utils import graph_to_adjacency, list_to_mask, vector_to_dict
9+
from graphblas_algorithms._utils import graph_to_adjacency, list_to_mask, vector_to_dict
1010

1111

1212
def get_properties(G, names, *, L=None, U=None, degrees=None, has_self_edges=True):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .pagerank_alg import pagerank

graphblas_algorithms/link_analysis.py renamed to graphblas_algorithms/algorithms/link_analysis/pagerank_alg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from graphblas import Vector, binary, unary
55
from graphblas.semiring import plus_first, plus_times
66

7-
from ._utils import dict_to_vector, graph_to_adjacency, vector_to_dict
7+
from graphblas_algorithms._utils import dict_to_vector, graph_to_adjacency, vector_to_dict
88

99

1010
def pagerank_core(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from graphblas_algorithms import pagerank
2+
3+
from networkx.algorithms.link_analysis.tests.test_pagerank import * # isort:skip

graphblas_algorithms/reciprocity.py renamed to graphblas_algorithms/algorithms/reciprocity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from networkx import NetworkXError
33
from networkx.utils import not_implemented_for
44

5-
from ._utils import graph_to_adjacency, list_to_mask, vector_to_dict
5+
from graphblas_algorithms._utils import graph_to_adjacency, list_to_mask, vector_to_dict
66

77

88
def reciprocity_core(G, mask=None):

graphblas_algorithms/algorithms/tests/__init__.py

Whitespace-only changes.

graphblas_algorithms/tests/test_cluster.py renamed to graphblas_algorithms/algorithms/tests/test_cluster.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import graphblas as gb
22
import networkx as nx
33

4-
import graphblas_algorithms as ga
5-
from graphblas_algorithms import average_clustering, clustering, transitivity, triangles # noqa
4+
from graphblas_algorithms import average_clustering, clustering, transitivity, triangles
5+
from graphblas_algorithms.algorithms import cluster
66

77

88
def test_triangles_full():
@@ -12,47 +12,47 @@ def test_triangles_full():
1212
G2 = gb.select.offdiag(G).new()
1313
L = gb.select.tril(G, -1).new(name="L")
1414
U = gb.select.triu(G, 1).new(name="U")
15-
result = ga.cluster.triangles_core(G, L=L, U=U)
15+
result = cluster.triangles_core(G, L=L, U=U)
1616
expected = gb.Vector(int, 5)
1717
expected[:] = 6
1818
assert result.isequal(expected)
19-
result = ga.cluster.triangles_core(G2, L=L, U=U)
19+
result = cluster.triangles_core(G2, L=L, U=U)
2020
assert result.isequal(expected)
2121
mask = gb.Vector(bool, 5)
2222
mask[0] = True
2323
mask[3] = True
24-
result = ga.cluster.triangles_core(G, mask=mask.S)
24+
result = cluster.triangles_core(G, mask=mask.S)
2525
expected = gb.Vector(int, 5)
2626
expected[0] = 6
2727
expected[3] = 6
2828
assert result.isequal(expected)
29-
result = ga.cluster.triangles_core(G2, mask=mask.S)
29+
result = cluster.triangles_core(G2, mask=mask.S)
3030
assert result.isequal(expected)
31-
assert ga.cluster.single_triangle_core(G, 1) == 6
32-
assert ga.cluster.single_triangle_core(G, 0, L=L) == 6
33-
assert ga.cluster.single_triangle_core(G2, 0, has_self_edges=False) == 6
34-
assert ga.cluster.total_triangles_core(G2) == 10
35-
assert ga.cluster.total_triangles_core(G) == 10
36-
assert ga.cluster.total_triangles_core(G, L=L, U=U) == 10
37-
assert ga.cluster.transitivity_core(G) == 1.0
38-
assert ga.cluster.transitivity_core(G2) == 1.0
39-
result = ga.cluster.clustering_core(G)
31+
assert cluster.single_triangle_core(G, 1) == 6
32+
assert cluster.single_triangle_core(G, 0, L=L) == 6
33+
assert cluster.single_triangle_core(G2, 0, has_self_edges=False) == 6
34+
assert cluster.total_triangles_core(G2) == 10
35+
assert cluster.total_triangles_core(G) == 10
36+
assert cluster.total_triangles_core(G, L=L, U=U) == 10
37+
assert cluster.transitivity_core(G) == 1.0
38+
assert cluster.transitivity_core(G2) == 1.0
39+
result = cluster.clustering_core(G)
4040
expected = gb.Vector(float, 5)
4141
expected[:] = 1
4242
assert result.isequal(expected)
43-
result = ga.cluster.clustering_core(G2)
43+
result = cluster.clustering_core(G2)
4444
assert result.isequal(expected)
45-
assert ga.cluster.single_clustering_core(G, 0) == 1
46-
assert ga.cluster.single_clustering_core(G2, 0) == 1
45+
assert cluster.single_clustering_core(G, 0) == 1
46+
assert cluster.single_clustering_core(G2, 0) == 1
4747
expected(mask.S, replace=True) << 1
48-
result = ga.cluster.clustering_core(G, mask=mask.S)
48+
result = cluster.clustering_core(G, mask=mask.S)
4949
assert result.isequal(expected)
50-
result = ga.cluster.clustering_core(G2, mask=mask.S)
50+
result = cluster.clustering_core(G2, mask=mask.S)
5151
assert result.isequal(expected)
52-
assert ga.cluster.average_clustering_core(G) == 1
53-
assert ga.cluster.average_clustering_core(G2) == 1
54-
assert ga.cluster.average_clustering_core(G, mask=mask.S) == 1
55-
assert ga.cluster.average_clustering_core(G2, mask=mask.S) == 1
52+
assert cluster.average_clustering_core(G) == 1
53+
assert cluster.average_clustering_core(G2) == 1
54+
assert cluster.average_clustering_core(G, mask=mask.S) == 1
55+
assert cluster.average_clustering_core(G2, mask=mask.S) == 1
5656

5757

5858
def test_directed(orig):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from graphblas_algorithms import overall_reciprocity, reciprocity
2+
3+
from networkx.algorithms.tests.test_reciprocity import * # isort:skip

graphblas_algorithms/tests/test_pagerank.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

graphblas_algorithms/tests/test_reciprocity.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.cfg

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
[aliases]
22
test=pytest
33

4-
[tool:pytest]
5-
testpaths = graphblas_algorithms/tests
6-
74
[flake8]
85
max-line-length = 100
96
inline-quotes = "
107
exclude =
118
versioneer.py,
12-
graphblas_algorithms/tests/,
9+
graphblas_algorithms/*/tests/,
10+
graphblas_algorithms/*/*/tests/,
1311
build/
1412
ignore =
1513
E203, # whitespace before ':'
1614
E231, # Multiple spaces around ","
1715
W503, # line break before binary operator
16+
per-file-ignores =
17+
__init__.py:F401,F403, # allow unused and star imports
18+
test_*.py:F401,F403,
1819
1920
[isort]
2021
sections = FUTURE,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER

0 commit comments

Comments
 (0)