8000 TST Extend tests for `scipy.sparse.*array` in `sklearn/preprocessing/tests/test_common.py` by work-mohit · Pull Request #27164 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

TST Extend tests for scipy.sparse.*array in sklearn/preprocessing/tests/test_common.py #27164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions sklearn/preprocessing/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import numpy as np
import pytest
from scipy import sparse

from sklearn.base import clone
from sklearn.datasets import load_iris
Expand All @@ -22,6 +21,15 @@
scale,
)
from sklearn.utils._testing import assert_allclose, assert_array_equal
from sklearn.utils.fixes import (
BSR_CONTAINERS,
COO_CONTAINERS,
CSC_CONTAINERS,
CSR_CONTAINERS,
DIA_CONTAINERS,
DOK_CONTAINERS,
LIL_CONTAINERS,
)

iris = load_iris()

Expand Down Expand Up @@ -113,19 +121,19 @@ def test_missing_value_handling(
Xt_dense = est_dense.fit(X_train).transform(X_test)
Xt_inv_dense = est_dense.inverse_transform(Xt_dense)

for sparse_constructor in (
sparse.csr_matrix,
sparse.csc_matrix,
sparse.bsr_matrix,
sparse.coo_matrix,
sparse.dia_matrix,
sparse.dok_matrix,
sparse.lil_matrix,
for sparse_container in (
BSR_CONTAINERS
+ COO_CONTAINERS
+ CSC_CONTAINERS
+ CSR_CONTAINERS
+ DIA_CONTAINERS
+ DOK_CONTAINERS
+ LIL_CONTAINERS
):
# check that the dense and sparse inputs lead to the same results
# precompute the matrix to avoid catching side warnings
X_train_sp = sparse_constructor(X_train)
X_test_sp = sparse_constructor(X_test)
X_train_sp = sparse_container(X_train)
X_test_sp = sparse_container(X_test)
with warnings.catch_warnings():
warnings.simplefilter("ignore", PendingDeprecationWarning)
warnings.simplefilter("error", RuntimeWarning)
Expand Down
0