File tree Expand file tree Collapse file tree 1 file changed +19
-11
lines changed
sklearn/preprocessing/tests Expand file tree Collapse file tree 1 file changed +19
-11
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import numpy as np
4
4
import pytest
5
- from scipy import sparse
6
5
7
6
from sklearn .base import clone
8
7
from sklearn .datasets import load_iris
22
21
scale ,
23
22
)
24
23
from sklearn .utils ._testing import assert_allclose , assert_array_equal
24
+ from sklearn .utils .fixes import (
25
+ BSR_CONTAINERS ,
26
+ COO_CONTAINERS ,
27
+ CSC_CONTAINERS ,
28
+ CSR_CONTAINERS ,
29
+ DIA_CONTAINERS ,
30
+ DOK_CONTAINERS ,
31
+ LIL_CONTAINERS ,
32
+ )
25
33
26
34
iris = load_iris ()
27
35
@@ -113,19 +121,19 @@ def test_missing_value_handling(
113
121
Xt_dense = est_dense .fit (X_train ).transform (X_test )
114
122
Xt_inv_dense = est_dense .inverse_transform (Xt_dense )
115
123
116
- for sparse_constructor in (
117
- sparse . csr_matrix ,
118
- sparse . csc_matrix ,
119
- sparse . bsr_matrix ,
120
- sparse . coo_matrix ,
121
- sparse . dia_matrix ,
122
- sparse . dok_matrix ,
123
- sparse . lil_matrix ,
124
+ for sparse_container in (
125
+ BSR_CONTAINERS
126
+ + COO_CONTAINERS
127
+ + CSC_CONTAINERS
128
+ + CSR_CONTAINERS
129
+ + DIA_CONTAINERS
130
+ + DOK_CONTAINERS
131
+ + LIL_CONTAINERS
124
132
):
125
133
# check that the dense and sparse inputs lead to the same results
126
134
# precompute the matrix to avoid catching side warnings
127
- X_train_sp = sparse_constructor (X_train )
128
- X_test_sp = sparse_constructor (X_test )
135
+ X_train_sp = sparse_container (X_train )
136
+ X_test_sp = sparse_container (X_test )
129
137
with warnings .catch_warnings ():
130
138
warnings .simplefilter ("ignore" , PendingDeprecationWarning )
131
139
warnings .simplefilter ("error" , RuntimeWarning )
You can’t perform that action at this time.
0 commit comments