Skip to content

Commit 444ee0d

Browse files
committed
Add viz motifs, fix deprecated scipy function
1 parent cad822b commit 444ee0d

File tree

1 file changed

+9
-8
lines changed
  • hypergraphx/communities/hypergraph_mt

1 file changed

+9
-8
lines changed

hypergraphx/communities/hypergraph_mt/model.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -248,14 +248,15 @@ def _check_fit_params(
248248
hypergraph.get_sizes()
249249
) # TODO: check whether we want to refactor the name of this variable
250250

251-
# Isolated nodes.
252-
self.isolates = np.where(self.incidence.getnnz(1) == 0)[
253-
0
254-
] # TODO: implement it as a core method
255-
# Non-isolated nodes.
256-
self.non_isolates = np.where(self.incidence.getnnz(1) != 0)[
257-
0
258-
] # TODO: implement it as a core method
251+
row_sums = self.incidence.sum(axis=1)
252+
# If row_sums is a matrix (e.g., from sparse), convert to 1D array
253+
if hasattr(row_sums, "A1"):
254+
row_sums = row_sums.A1
255+
else:
256+
row_sums = np.asarray(row_sums).flatten()
257+
258+
self.isolates = np.where(row_sums == 0)[0]
259+
self.non_isolates = np.where(row_sums != 0)[0]
259260

260261
# Normalize u such that every row sums to 1.
261262
self.normalizeU = normalizeU

0 commit comments

Comments
 (0)