Skip to content

Commit 34ec4ea

Browse files
committed
Scipy.sparse may only accept arrays, not lists
1 parent 824f7aa commit 34ec4ea

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sklearn/svm/tests/test_sparse.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ def test_unsorted_indices():
113113

114114
# reverse each row's indices
115115
def scramble_indices(X):
116-
new_data = []
117-
new_indices = []
116+
new_data = np.empty_like(X.data)
117+
new_indices = np.empty_like(X.indices)
118118
for i in range(1, len(X.indptr)):
119119
row_slice = slice(*X.indptr[i - 1: i + 1])
120-
new_data.extend(X.data[row_slice][::-1])
121-
new_indices.extend(X.indices[row_slice][::-1])
120+
new_data[row_slice] = X.data[row_slice][::-1]
121+
new_indices[row_slice] = X.indices[row_slice][::-1]
122122
return sparse.csr_matrix((new_data, new_indices, X.indptr),
123123
shape=X.shape)
124124

0 commit comments

Comments
 (0)