File tree Expand file tree Collapse file tree 3 files changed +23
-28
lines changed Expand file tree Collapse file tree 3 files changed +23
-28
lines changed Original file line number Diff line number Diff line change 2
2
from .robust_single_linkage_ import RobustSingleLinkage , robust_single_linkage
3
3
from .validity import validity_index
4
4
from .prediction import approximate_predict , membership_vector , all_points_membership_vectors
5
- from .utils import if_matplotlib
6
5
7
6
Original file line number Diff line number Diff line change 22
22
validity_index ,
23
23
approximate_predict ,
24
24
membership_vector ,
25
- all_points_membership_vectors ,
26
- if_matplotlib )
25
+ all_points_membership_vectors )
27
26
# from sklearn.cluster.tests.common import generate_clustered_data
28
27
from sklearn .datasets import make_blobs
29
28
from sklearn .utils import shuffle
45
44
X = StandardScaler ().fit_transform (X )
46
45
47
46
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
+
48
69
def if_pandas (func ):
49
70
"""Test decorator that skips test if pandas not installed."""
50
71
@wraps (func )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments