Improve warning when using np.ndarray subsets (#6934)

This commit is contained in:
Jose Manuel Llorens 2021-05-04 07:24:41 +02:00 committed by GitHub
parent b35dd76dca
commit 4ddbaeea32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -117,9 +117,10 @@ def _maybe_np_slice(data, dtype):
try:
if not data.flags.c_contiguous:
warnings.warn(
"Use subset (sliced data) of np.ndarray is not recommended " +
"Use of np.ndarray subsets (sliced data) is not recommended " +
"because it will generate extra copies and increase " +
"memory consumption")
"memory consumption. Consider using np.ascontiguousarray to " +
"make the array contiguous.")
data = np.array(data, copy=True, dtype=dtype)
else:
data = np.array(data, copy=False, dtype=dtype)