Skip to content

Commit 4bcfc92

Browse files
committed
Add deprecation starting version to warning message
1 parent 50cd194 commit 4bcfc92

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

sklearn/utils/tests/test_validation.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,26 @@ def test_check_array():
249249
X_str = [['a', 'b'], ['c', 'd']]
250250
assert_warns_message(
251251
DeprecationWarning,
252-
"array with dtype {} will be handled as object".format(np.dtype('U1')),
252+
"arrays with dtype {} will be handled as arrays with dtype object"
253+
.format(np.dtype('U1')),
253254
check_array, X_str, "numeric")
254255
assert_warns_message(
255256
DeprecationWarning,
256-
"array with dtype {} will be handled as object".format(np.dtype('U1')),
257+
"arrays with dtype {} will be handled as arrays with dtype object"
258+
.format(np.dtype('U1')),
257259
check_array, np.array(X_str, dtype='U1'), "numeric")
258260

259261
# deprecation warning if byte-like array with dtype="numeric"
260262
X_byte = [[b'a', b'b'], [b'c', b'd']]
261263
assert_warns_message(
262264
DeprecationWarning,
263-
"array with dtype {} will be handled as object".format(np.dtype('S1')),
265+
"arrays with dtype {} will be handled as arrays with dtype object"
266+
.format(np.dtype('S1')),
264267
check_array, np.array(X_byte, dtype='S1'), "numeric")
265268
assert_warns_message(
266269
DeprecationWarning,
267-
"array with dtype {} will be handled as object".format(np.dtype('V1')),
270+
"arrays with dtype {} will be handled as arrays with dtype object"
271+
.format(np.dtype('V1')),
268272
check_array, np.array(X_byte, dtype='V1'), "numeric")
269273

270274

sklearn/utils/validation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,9 @@ def check_array(array, accept_sparse=False, dtype="numeric", order=None,
479479
# in the future np.flexible dtypes will be handled like object dtypes
480480
if dtype_numeric and np.issubdtype(array.dtype, np.flexible):
481481
warnings.warn(
482-
"In the future, array with dtype {} will be handled as object,"
483-
" and will be attempted to be cast to numeric.".format(
482+
"Beginning in version 0.22, arrays with dtype {} will be "
483+
"handled as arrays with dtype object, and will be attempted "
484+
"to be cast to numeric.".format(
484485
array.dtype), DeprecationWarning)
485486

486487
# make sure we actually converted to numeric:

0 commit comments

Comments
 (0)