Skip to content

Commit 6a3365d

Browse files
committed
ENH use astype to avoid unnecessary copy
1 parent 5029db7 commit 6a3365d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sklearn/preprocessing/imputation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ def transform(self, X):
356356
indexes = np.repeat(np.arange(len(X.indptr) - 1, dtype=np.int),
357357
np.diff(X.indptr))[mask]
358358

359-
X.data[mask] = valid_statistics[indexes].astype(X.dtype)
359+
X.data[mask] = astype(valid_statistics[indexes], X.dtype,
360+
copy=False)
360361
else:
361362
if sparse.issparse(X):
362363
X = X.toarray()

0 commit comments

Comments
 (0)