Skip to content

Commit 50dde09

Browse files
authored
TST Extend tests for scipy.sparse.*array in test_mlp.py (scikit-learn#27163)
1 parent 1b2b871 commit 50dde09

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sklearn/neural_network/tests/test_mlp.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
assert_almost_equal,
1919
assert_array_equal,
2020
)
21-
from scipy.sparse import csr_matrix
2221

2322
from sklearn.datasets import (
2423
load_digits,
@@ -31,6 +30,7 @@
3130
from sklearn.neural_network import MLPClassifier, MLPRegressor
3231
from sklearn.preprocessing import LabelBinarizer, MinMaxScaler, scale
3332
from sklearn.utils._testing import ignore_warnings
33+
from sklearn.utils.fixes import CSR_CONTAINERS
3434

3535
ACTIVATION_TYPES = ["identity", "logistic", "tanh", "relu"]
3636

@@ -626,11 +626,12 @@ def test_shuffle():
626626
assert not np.array_equal(mlp1.coefs_[0], mlp2.coefs_[0])
627627

628628

629-
def test_sparse_matrices():
629+
@pytest.mark.parametrize("csr_container", CSR_CONTAINERS)
630+
def test_sparse_matrices(csr_container):
630631
# Test that sparse and dense input matrices output the same results.
631632
X = X_digits_binary[:50]
632633
y = y_digits_binary[:50]
633-
X_sparse = csr_matrix(X)
634+
X_sparse = csr_container(X)
634635
mlp = MLPClassifier(solver="lbfgs", hidden_layer_sizes=15, random_state=1)
635636
mlp.fit(X, y)
636637
pred1 = mlp.predict(X)

0 commit comments

Comments
 (0)