11import pytest
22from sklearn .metrics import v_measure_score
33
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+
57try :
68 from flowsom .models .pyflowsom_estimator import PyFlowSOMEstimator
79except ImportError :
810 from flowsom .models import FlowSOMEstimator as PyFlowSOMEstimator
911
1012
11- @pytest .importorskip ("flowsom.models.pyflowsom_estimator" )
1213def test_clustering (X ):
1314 fsom = PyFlowSOMEstimator (n_clusters = 10 )
1415 y_pred = fsom .fit_predict (X )
1516 assert y_pred .shape == (100 ,)
1617
1718
18- @pytest .importorskip ("flowsom.models.pyflowsom_estimator" )
1919def test_clustering_v_measure (X_and_y ):
2020 som = PyFlowSOMEstimator (n_clusters = 10 )
2121 X , y_true = X_and_y
@@ -24,7 +24,6 @@ def test_clustering_v_measure(X_and_y):
2424 assert score > 0.7
2525
2626
27- @pytest .importorskip ("flowsom.models.pyflowsom_estimator" )
2827def test_reproducibility_no_seed (X ):
2928 fsom_1 = PyFlowSOMEstimator (n_clusters = 10 )
3029 fsom_2 = PyFlowSOMEstimator (n_clusters = 10 )
@@ -34,7 +33,6 @@ def test_reproducibility_no_seed(X):
3433 assert not all (y_pred_1 == y_pred_2 )
3534
3635
37- @pytest .importorskip ("flowsom.models.pyflowsom_estimator" )
3836def test_reproducibility_seed (X ):
3937 fsom_1 = PyFlowSOMEstimator (n_clusters = 10 , seed = 0 )
4038 fsom_2 = PyFlowSOMEstimator (n_clusters = 10 , seed = 0 )
0 commit comments