8000 remove order checks for sparse matrices · scikit-learn/scikit-learn@0949a2e · GitHub
[go: up one dir, main page]

Skip to content

Commit 0949a2e

Browse files
author
Immanuel Bayer
committed
remove order checks for sparse matrices
1 parent cb219b4 commit 0949a2e

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

sklearn/utils/tests/test_validation.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,6 @@ def test_ordering():
106106
X.data = X.data[::-1]
107107
assert_false(X.data.flags['C_CONTIGUOUS'])
108108

109-
for copy in (True, False):
110-
Y = check_array(X, accept_sparse='csr', copy=copy, order='C')
111-
assert_true(Y.data.flags['C_CONTIGUOUS'])
112-
113109

114110
def test_check_array():
115111
# accept_sparse == None

sklearn/utils/validation.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def indexable(*iterables):
200200
return result
201201

202202

203-
def _ensure_sparse_format(spmatrix, accept_sparse, dtype, order, copy,
203+
def _ensure_sparse_format(spmatrix, accept_sparse, dtype, copy,
204204
force_all_finite):
205205
"""Convert a sparse matrix to a given format.
206206
@@ -220,9 +220,6 @@ def _ensure_sparse_format(spmatrix, accept_sparse, dtype, order, copy,
220220
dtype : string, type or None (default=none)
221221
Data type of result. If None, the dtype of the input is preserved.
222222
223-
order : 'F', 'C' or None (default=None)
224-
Whether an array will be forced to be fortran or c-style.
225-
226223
copy : boolean (default=False)
227224
Whether a forced copy will be triggered. If copy=False, a copy might
228225
be triggered by a conversion.
@@ -260,8 +257,6 @@ def _ensure_sparse_format(spmatrix, accept_sparse, dtype, order, copy,
260257
% spmatrix.format)
261258
else:
262259
_assert_all_finite(spmatrix.data)
263-
if hasattr(spmatrix, "data"):
264-
spmatrix.data = np.array(spmatrix.data, copy=False, order=order)
265260
return spmatrix
266261

267262

@@ -330,8 +325,8 @@ def check_array(array, accept_sparse=None, dtype="numeric", order=None,
330325
if sp.issparse(array):
331326
if dtype_numeric:
332327
dtype = None
333-
array = _ensure_sparse_format(array, accept_sparse, dtype, order,
334-
copy, force_all_finite)
328+
array = _ensure_sparse_format(array, accept_sparse, dtype, copy,
329+
force_all_finite)
335330
else:
336331
if ensure_2d:
337332
array = np.atleast_2d(array)

0 commit comments

Comments
 (0)
0