Skip to content

Commit 4b87997

Browse files
authored
TST Extend tests for scipy.sparse.*array in sklearn/tests/test_pipeline.py (scikit-learn#27278)
1 parent 3dd4906 commit 4b87997

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sklearn/tests/test_pipeline.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import joblib
1111
import numpy as np
1212
import pytest
13-
from scipy import sparse
1413

1514
from sklearn.base import BaseEstimator, TransformerMixin, clone, is_classifier
1615
from sklearn.cluster import KMeans
@@ -46,6 +45,7 @@
4645
assert_array_almost_equal,
4746
assert_array_equal,
4847
)
48+
from sklearn.utils.fixes import CSR_CONTAINERS
4949
from sklearn.utils.validation import check_is_fitted
5050

5151
iris = load_iris()
@@ -485,7 +485,8 @@ def test_predict_methods_with_predict_params(method_name):
485485
assert pipe.named_steps["clf"].got_attribute
486486

487487

488-
def test_feature_union():
488+
@pytest.mark.parametrize("csr_container", CSR_CONTAINERS)
489+
def test_feature_union(csr_container):
489490
# basic sanity check for feature union
490491
X = iris.data
491492
X -= X.mean(axis=0)
@@ -504,7 +505,7 @@ def test_feature_union():
504505
# test if it also works for sparse input
505506
# We use a different svd object to control the random_state stream
506507
fs = FeatureUnion([("svd", svd), ("select", select)])
507-
X_sp = sparse.csr_matrix(X)
508+
X_sp = csr_container(X)
508509
X_sp_transformed = fs.fit_transform(X_sp, y)
509510
assert_array_almost_equal(X_transformed, X_sp_transformed.toarray())
510511

0 commit comments

Comments
 (0)