From 4ddbaeea32b598d5daf4b8a71ecd51199de1c41e Mon Sep 17 00:00:00 2001 From: Jose Manuel Llorens Date: Tue, 4 May 2021 07:24:41 +0200 Subject: [PATCH] Improve warning when using np.ndarray subsets (#6934) --- python-package/xgboost/data.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python-package/xgboost/data.py b/python-package/xgboost/data.py index 002f801ef..b664fc3a2 100644 --- a/python-package/xgboost/data.py +++ b/python-package/xgboost/data.py @@ -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)