From bfe71d319aa5de26908e81fe085e8bf2667b8916 Mon Sep 17 00:00:00 2001 From: arnaudon Date: Tue, 14 Nov 2023 14:48:59 +0100 Subject: [PATCH] fix --- src/pygenstability/pygenstability.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/pygenstability/pygenstability.py b/src/pygenstability/pygenstability.py index 6e13a32..e9be998 100644 --- a/src/pygenstability/pygenstability.py +++ b/src/pygenstability/pygenstability.py @@ -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 @@ -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"