8000 Code review edits. · scikit-learn/scikit-learn@4301144 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4301144

Browse files
author
Oleh Kozynets
committed
Code review edits.
1 parent cf34c0c commit 4301144

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sklearn/utils/multiclass.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,15 @@ def is_multilabel(y):
140140
import warnings
141141

142142
if hasattr(y, '__array__') or isinstance(y, Sequence):
143+
# TODO: Replace the warning context manager with a try-except statement
144+
# DeprecationWarning will be replaced by ValueError, see NEP 34
143145
with warnings.catch_warnings():
144146
warnings.simplefilter('error', np.VisibleDeprecationWarning)
145147
try:
146148
y = np.asarray(y)
147149
except np.VisibleDeprecationWarning:
150+
# dtype=object should be provided explicitly for ragged arrays,
151+
# see NEP 34
148152
y = np.array(y, dtype=object)
149153

150154
if not (hasattr(y, "shape") and y.ndim == 2 and y.shape[1] > 1):
@@ -260,11 +264,15 @@ def type_of_target(y):
260264
if is_multilabel(y):
261265
return 'multilabel-indicator'
262266

267+
# TODO: Replace the warning context manager with a try-except statement
268+
# DeprecationWarning will be replaced by ValueError, see NEP 34
263269
with warnings.catch_warnings():
264270
warnings.simplefilter('error', np.VisibleDeprecationWarning)
265271
try:
266272
y = np.asarray(y)
267273
except np.VisibleDeprecationWarning:
274+
# dtype=object should be provided explicitly for ragged arrays,
275+
# see NEP 34
268276
y = np.asarray(y, dtype=object)
269277

270278
# The old sequence of sequences format

0 commit comments

Comments
 (0)
0