Skip to content

Commit

Permalink
Pull request #204: Hotfix/test lint
Browse files Browse the repository at this point in the history
Merge in HYP/hypernetx from hotfix/test-lint to master

* commit '10bd14e70d99f96dd3c841289f909769c25d6c62':
  bump: version 2.3.5 → 2.3.6
  pre-commit edits
  remove numpy required version
  fixed some typos and updated the version of scipy
  updated test suite to use .toarray instead of .A to transform csr_matrix to numpy array
  pre-commit and version tag
  pre-commit and version tag
  • Loading branch information
ryandanehy committed Aug 14, 2024
2 parents 4a5c851 + 10bd14e commit 8d53061
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .cz.toml
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion hypernetx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
from hypernetx.utils import *
from hypernetx.utils.toys import *

__version__ = "2.3.5"
__version__ = "2.3.6"
10 changes: 7 additions & 3 deletions hypernetx/algorithms/hypergraph_modularity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>", "Dustin Arendt <[email protected]>",
"Sinan Aksoy <[email protected]>", "Emilie Purvine <[email protected]>",
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/classes/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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],
Expand Down
18 changes: 13 additions & 5 deletions tests/classes/test_hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)


Expand All @@ -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)


Expand All @@ -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)


Expand All @@ -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)


Expand Down

0 comments on commit 8d53061

Please sign in to comment.