10
10
import joblib
11
11
import numpy as np
12
12
import pytest
13
- from scipy import sparse
14
13
15
14
from sklearn .base import BaseEstimator , TransformerMixin , clone , is_classifier
16
15
from sklearn .cluster import KMeans
46
45
assert_array_almost_equal ,
47
46
assert_array_equal ,
48
47
)
48
+ from sklearn .utils .fixes import CSR_CONTAINERS
49
49
from sklearn .utils .validation import check_is_fitted
50
50
51
51
iris = load_iris ()
@@ -485,7 +485,8 @@ def test_predict_methods_with_predict_params(method_name):
485
485
assert pipe .named_steps ["clf" ].got_attribute
486
486
487
487
488
- def test_feature_union ():
488
+ @pytest .mark .parametrize ("csr_container" , CSR_CONTAINERS )
489
+ def test_feature_union (csr_container ):
489
490
# basic sanity check for feature union
490
491
X = iris .data
491
492
X -= X .mean (axis = 0 )
@@ -504,7 +505,7 @@ def test_feature_union():
504
505
# test if it also works for sparse input
505
506
# We use a different svd object to control the random_state stream
506
507
fs = FeatureUnion ([("svd" , svd ), ("select" , select )])
507
- X_sp = sparse . csr_matrix (X )
508
+ X_sp = csr_container (X )
508
509
X_sp_transformed = fs .fit_transform (X_sp , y )
509
510
assert_array_almost_equal (X_transformed , X_sp_transformed .toarray ())
510
511
0 commit comments