Skip to content

Commit

Permalink
fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
nwlandry committed Jul 2, 2024
1 parent 301fb8e commit 8fd7fd6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions xgi/algorithms/centrality.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ def clique_eigenvector_centrality(H, tol=1e-6):
if not is_connected(H):
return {n: np.nan for n in H.nodes}
W, node_dict = clique_motif_matrix(H, index=True)
_, v = eigsh(W.asfptype(), k=1, which="LM", tol=tol)

try:
_, v = eigsh(W.astype(float), k=1, which="LM", tol=tol)
except AttributeError:
_, v = eigsh(W.asfptype(), k=1, which="LM", tol=tol)

# multiply by the sign to try and enforce positivity
v = np.sign(v[0]) * v / norm(v, 1)
return {node_dict[n]: v[n].item() for n in node_dict}
Expand Down

0 comments on commit 8fd7fd6

Please sign in to comment.