Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudon committed Nov 14, 2023
1 parent a24eed3 commit bfe71d3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/pygenstability/pygenstability.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@
from sklearn.metrics.cluster import entropy
from tqdm import tqdm

from pygenstability import generalized_louvain
try:
from pygenstability import generalized_louvain

_NO_LOUVAIN = False
except ImportError:
_NO_LOUVAIN = True

from pygenstability.constructors import load_constructor
from pygenstability.io import save_results
from pygenstability.optimal_scales import identify_optimal_scales
Expand Down Expand Up @@ -108,10 +114,10 @@ def _get_constructor_data(constructor, scales, pool, tqdm_disable=False):


def _check_method(method): # pragma: no cover
if _NO_LEIDEN and not hasattr(generalized_louvain, "evaluate_quality"):
if _NO_LEIDEN and _NO_LOUVAIN:
raise Exception("Without Louvain or Leiden solver, we cannot run PyGenStability")

if method == "louvain" and not hasattr(generalized_louvain, "evaluate_quality"):
if method == "louvain" and _NO_LOUVAIN:
print("Louvain is not available, we fallback to leiden.")
return "leiden"

Expand Down

0 comments on commit bfe71d3

Please sign in to comment.