@@ -151,20 +151,6 @@ def check_consistent_length(*arrays):
151
151
% str (uniques ))
152
152
153
153
154
- def _get_sparse_type_string (sparse_matrix ):
155
- """Return string representation of sparse matrix format of input"""
156
- formats = ['csr' , 'csc' , 'coo' , 'dok' , 'lil' , 'dia' , 'bsr' ]
157
- type_checkers = [sp .isspmatrix_csr , sp .isspmatrix_csc , sp .isspmatrix_coo ,
158
- sp .isspmatrix_dok , sp .isspmatrix_lil , sp .isspmatrix_dia ,
159
- sp .isspmatrix_bsr ]
160
- for type_checker , s in zip (type_checkers , formats ):
161
- if type_checker (sparse_matrix ):
162
- return s
163
- else :
164
- raise ValueError ("Unknown sparse matrix format passed: %s"
165
- % type (sparse_matrix ))
166
-
167
-
168
154
def _sparse_matrix_constructor (string_format ):
169
155
"""Get constructor from a sparse matrix string format."""
170
156
if string_format == "csr" :
@@ -218,7 +204,7 @@ def _ensure_sparse_format(spmatrix, allowed_sparse, dtype, order, copy,
218
204
raise TypeError ('A sparse matrix was passed, but dense '
219
205
'data is required. Use X.toarray() to '
220
206
'convert to a dense numpy array.' )
221
- sparse_type = _get_sparse_type_string ( spmatrix )
207
+ sparse_type = spmatrix . format
222
208
if sparse_type in allowed_sparse :
223
209
# correct type
224
210
if dtype == spmatrix .dtype or dtype is None :
0 commit comments