1
1
import pytest
2
2
from sklearn .metrics import v_measure_score
3
3
4
- # optional import if pyFlowSOM is installed, otherwise use regular FlowSOM for type checking
4
+ # Skip the entire test file if pyflowsom is not installed
5
+ pytest .importorskip ("pyFlowSOM" , reason = "pyflowsom is not installed" )
6
+
5
7
try :
6
8
from flowsom .models .pyflowsom_estimator import PyFlowSOMEstimator
7
9
except ImportError :
8
10
from flowsom .models import FlowSOMEstimator as PyFlowSOMEstimator
9
11
10
12
11
- @pytest .importorskip ("flowsom.models.pyflowsom_estimator" )
12
13
def test_clustering (X ):
13
14
fsom = PyFlowSOMEstimator (n_clusters = 10 )
14
15
y_pred = fsom .fit_predict (X )
15
16
assert y_pred .shape == (100 ,)
16
17
17
18
18
- @pytest .importorskip ("flowsom.models.pyflowsom_estimator" )
19
19
def test_clustering_v_measure (X_and_y ):
20
20
som = PyFlowSOMEstimator (n_clusters = 10 )
21
21
X , y_true = X_and_y
@@ -24,7 +24,6 @@ def test_clustering_v_measure(X_and_y):
24
24
assert score > 0.7
25
25
26
26
27
- @pytest .importorskip ("flowsom.models.pyflowsom_estimator" )
28
27
def test_reproducibility_no_seed (X ):
29
28
fsom_1 = PyFlowSOMEstimator (n_clusters = 10 )
30
29
fsom_2 = PyFlowSOMEstimator (n_clusters = 10 )
@@ -34,7 +33,6 @@ def test_reproducibility_no_seed(X):
34
33
assert not all (y_pred_1 == y_pred_2 )
35
34
36
35
37
- @pytest .importorskip ("flowsom.models.pyflowsom_estimator" )
38
36
def test_reproducibility_seed (X ):
39
37
fsom_1 = PyFlowSOMEstimator (n_clusters = 10 , seed = 0 )
40
38
fsom_2 = PyFlowSOMEstimator (n_clusters = 10 , seed = 0 )
0 commit comments