@@ -140,11 +140,15 @@ def is_multilabel(y):
140
140
import warnings
141
141
142
142
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
143
145
with warnings .catch_warnings ():
144
146
warnings .simplefilter ('error' , np .VisibleDeprecationWarning )
145
147
try :
146
148
y = np .asarray (y )
147
149
except np .VisibleDeprecationWarning :
150
+ # dtype=object should be provided explicitly for ragged arrays,
151
+ # see NEP 34
148
152
y = np .array (y , dtype = object )
149
153
150
154
if not (hasattr (y , "shape" ) and y .ndim == 2 and y .shape [1 ] > 1 ):
@@ -260,11 +264,15 @@ def type_of_target(y):
260
264
if is_multilabel (y ):
261
265
return 'multilabel-indicator'
262
266
267
+ # TODO: Replace the warning context manager with a try-except statement
268
+ # DeprecationWarning will be replaced by ValueError, see NEP 34
263
269
with warnings .catch_warnings ():
264
270
warnings .simplefilter ('error' , np .VisibleDeprecationWarning )
265
271
try :
266
272
y = np .asarray (y )
267
273
except np .VisibleDeprecationWarning :
274
+ # dtype=object should be provided explicitly for ragged arrays,
275
+ # see NEP 34
268
276
y = np .asarray (y , dtype = object )
269
277
270
278
# The old sequence of sequences format
0 commit comments