Skip to content

Commit 69acfb8

Browse files
authored
Merge pull request #298 from areeh/master
fix Nose being imported outside tests
2 parents 295d74f + 2461a22 commit 69acfb8

File tree

3 files changed

+23
-28
lines changed

3 files changed

+23
-28
lines changed

hdbscan/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
from .robust_single_linkage_ import RobustSingleLinkage, robust_single_linkage
33
from .validity import validity_index
44
from .prediction import approximate_predict, membership_vector, all_points_membership_vectors
5-
from .utils import if_matplotlib
65

76

hdbscan/tests/test_hdbscan.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
validity_index,
2323
approximate_predict,
2424
membership_vector,
25-
all_points_membership_vectors,
26-
if_matplotlib)
25+
all_points_membership_vectors)
2726
# from sklearn.cluster.tests.common import generate_clustered_data
2827
from sklearn.datasets import make_blobs
2928
from sklearn.utils import shuffle
@@ -45,6 +44,28 @@
4544
X = StandardScaler().fit_transform(X)
4645

4746

47+
def if_matplotlib(func):
48+
"""Test decorator that skips test if matplotlib not installed.
49+
50+
Parameters
51+
----------
52+
func
53+
"""
54+
@wraps(func)
55+
def run_test(*args, **kwargs):
56+
try:
57+
import matplotlib
58+
matplotlib.use('Agg', warn=False)
59+
# this fails if no $DISPLAY specified
60+
import matplotlib.pyplot as plt
61+
plt.figure()
62+
except ImportError:
63+
raise SkipTest('Matplotlib not available.')
64+
else:
65+
return func(*args, **kwargs)
66+
return run_test
67+
68+
4869
def if_pandas(func):
4970
"""Test decorator that skips test if pandas not installed."""
5071
@wraps(func)

hdbscan/utils.py

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)