8000 remove reimplementation of .format property lol · scikit-learn/scikit-learn@f72aa17 · GitHub
[go: up one dir, main page]

Skip to content

Commit f72aa17

Browse files
committed
remove reimplementation of .format property lol
1 parent 9756245 commit f72aa17

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

sklearn/utils/validation.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,6 @@ def check_consistent_length(*arrays):
151151
% str(uniques))
152152

153153

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-
168154
def _sparse_matrix_constructor(string_format):
169155
"""Get constructor from a sparse matrix string format."""
170156
if string_format == "csr":
@@ -218,7 +204,7 @@ def _ensure_sparse_format(spmatrix, allowed_sparse, dtype, order, copy,
218204
raise TypeError('A sparse matrix was passed, but dense '
219205
'data is required. Use X.toarray() to '
220206
'convert to a dense numpy array.')
221-
sparse_type = _get_sparse_type_string(spmatrix)
207+
sparse_type = spmatrix.format
222208
if sparse_type in allowed_sparse:
223209
# correct type
224210
if dtype == spmatrix.dtype or dtype is None:

0 commit comments

Comments
 (0)
0