Skip to content

Commit 4150941

Browse files
committed
Filter SyntaxWarning by message instead of module
Use message='invalid escape sequence' pattern which reliably matches the hdbscan warnings regardless of module name resolution.
1 parent 23da1c5 commit 4150941

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

hypertools/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import warnings
44

5-
warnings.filterwarnings("ignore", category=SyntaxWarning, module="hdbscan")
5+
warnings.filterwarnings(
6+
"ignore", category=SyntaxWarning, message="invalid escape sequence"
7+
)
68

79
from .config import __version__
810
from .plot.plot import plot

hypertools/tools/cluster.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
}
2424

2525
try:
26-
with warnings.catch_warnings():
27-
warnings.filterwarnings("ignore", category=SyntaxWarning, module="hdbscan")
28-
from hdbscan import HDBSCAN
26+
from hdbscan import HDBSCAN
27+
2928
_has_hdbscan = True
3029
models.update({"HDBSCAN": HDBSCAN})
3130
except ImportError:

0 commit comments

Comments
 (0)