diff --git a/.cz.toml b/.cz.toml index a1215f5c..c31d7848 100644 --- a/.cz.toml +++ b/.cz.toml @@ -1,6 +1,6 @@ [tool.commitizen] name = "cz_conventional_commits" -version = "2.3.5" +version = "2.3.6" version_provider = "poetry" version_files = [ "pyproject.toml", diff --git a/docs/source/conf.py b/docs/source/conf.py index fc65e2c6..bb2695a5 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -19,7 +19,7 @@ import os -__version__ = "2.3.5" +__version__ = "2.3.6" # If extensions (or modules to document with autodoc) are in another directory, diff --git a/hypernetx/__init__.py b/hypernetx/__init__.py index 6a19503d..f0b7699a 100644 --- a/hypernetx/__init__.py +++ b/hypernetx/__init__.py @@ -11,4 +11,4 @@ from hypernetx.utils import * from hypernetx.utils.toys import * -__version__ = "2.3.5" +__version__ = "2.3.6" diff --git a/hypernetx/algorithms/hypergraph_modularity.py b/hypernetx/algorithms/hypergraph_modularity.py index f29efe3b..a132ed43 100644 --- a/hypernetx/algorithms/hypergraph_modularity.py +++ b/hypernetx/algorithms/hypergraph_modularity.py @@ -183,7 +183,11 @@ def modularity(HG, A, wdc=linear): _df = pd.DataFrame(zip(_keys, _vals), columns=["key", "val"]) _df = _df.groupby(by="key").sum() EC = sum( - [wdc(k[1], k[0]) * v.iloc[0] for (k, v) in _df.iterrows() if k[0] > k[1] / 2] + [ + wdc(k[1], k[0]) * v.iloc[0] + for (k, v) in _df.iterrows() + if k[0] > k[1] / 2 + ] ) ## Degree Tax @@ -294,8 +298,8 @@ def two_section(HG): G = ig.Graph.TupleList(s, weights=True).simplify(combine_edges="sum") ## add isolates if any - isolates = list(set([v for v in HG.nodes]) - set(G.vs['name'])) - if len(isolates)>0: + isolates = list(set([v for v in HG.nodes]) - set(G.vs["name"])) + if len(isolates) > 0: G.add_vertices(isolates) return G diff --git a/pyproject.toml b/pyproject.toml index a81215b6..4a24be40 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "hypernetx" -version = "2.3.5" +version = "2.3.6" description = "HyperNetX is a Python library for the creation and study of hypergraphs." authors = ["Brenda Praggastis ", "Dustin Arendt ", "Sinan Aksoy ", "Emilie Purvine ", @@ -29,6 +29,7 @@ scikit-learn = ">=1.4.2" celluloid = ">=0.2.0" igraph = ">=0.11.4" decorator = ">=5.1.1" +scipy = ">=1.13" [tool.poetry.group.widget] optional = true diff --git a/tests/classes/conftest.py b/tests/classes/conftest.py index 52712d8f..4d2aec86 100644 --- a/tests/classes/conftest.py +++ b/tests/classes/conftest.py @@ -86,7 +86,7 @@ def __init__(self): [0, 0, 0, 0, 0, 1], ] ) - self.s1_adjacency_matrx = scipy.sparse.csr_matrix( + self.s1_adjacency_matrix = scipy.sparse.csr_matrix( [ [0, 1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 0, 0, 0], @@ -97,7 +97,7 @@ def __init__(self): [1, 0, 0, 1, 0, 1, 0], ] ) - self.s1_edge_adjacency_matrx = scipy.sparse.csr_matrix( + self.s1_edge_adjacency_matrix = scipy.sparse.csr_matrix( [ [0, 0, 1, 1, 0, 1], [0, 0, 0, 1, 1, 0], diff --git a/tests/classes/test_hypergraph.py b/tests/classes/test_hypergraph.py index 341c2e5e..708bb968 100644 --- a/tests/classes/test_hypergraph.py +++ b/tests/classes/test_hypergraph.py @@ -1093,7 +1093,9 @@ def test_incidence_matrix(sevenbysix): len(sevenbysix.nodes), len(sevenbysix.edges), ) - assert np.allclose(incidence_matrix.A, sevenbysix.incidence_matrix.A) + assert np.allclose( + incidence_matrix.toarray(), sevenbysix.incidence_matrix.toarray() + ) # check the edge and node indexes assert nodes_idx.tolist() == list(sevenbysix.nodes) @@ -1109,7 +1111,9 @@ def test_adjacency_matrix(sevenbysix): len(sevenbysix.nodes), len(sevenbysix.nodes), ) - assert np.allclose(adjacency_matrix.A, sevenbysix.s1_adjacency_matrx.A) + assert np.allclose( + adjacency_matrix.toarray(), sevenbysix.s1_adjacency_matrix.toarray() + ) assert node_idx.tolist() == list(sevenbysix.nodes) @@ -1122,7 +1126,9 @@ def test_edge_adjacency_matrix(sevenbysix): len(sevenbysix.edges), len(sevenbysix.edges), ) - assert np.allclose(adjacency_matrix.A, sevenbysix.s1_edge_adjacency_matrx.A) + assert np.allclose( + adjacency_matrix.toarray(), sevenbysix.s1_edge_adjacency_matrix.toarray() + ) assert node_idx.tolist() == list(sevenbysix.edges) @@ -1132,7 +1138,7 @@ def test_auxiliary_matrix_on_nodes(sevenbysix): aux_matrix, indexes = hg.auxiliary_matrix(index=True) assert aux_matrix.todense().shape == (len(sevenbysix.nodes), len(sevenbysix.nodes)) - assert np.allclose(aux_matrix.A, sevenbysix.s1_adjacency_matrx.A) + assert np.allclose(aux_matrix.toarray(), sevenbysix.s1_adjacency_matrix.toarray()) assert indexes.tolist() == list(sevenbysix.nodes) @@ -1142,7 +1148,9 @@ def test_auxiliary_matrix_on_edges(sevenbysix): aux_matrix, indexes = hg.auxiliary_matrix(node=False, index=True) assert aux_matrix.todense().shape == (len(sevenbysix.edges), len(sevenbysix.edges)) - assert np.allclose(aux_matrix.A, sevenbysix.s1_edge_adjacency_matrx.A) + assert np.allclose( + aux_matrix.toarray(), sevenbysix.s1_edge_adjacency_matrix.toarray() + ) assert indexes.tolist() == list(sevenbysix.edges)