-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
Related to the multiple issues about np.array(x) emitting a deprecation warning, it appears that np.testing.assert_array_equal emits a warning when the arguments get cast to an object array. This should probably not emit such a warning:
>>> import numpy as np
>>> import warnings
>>> warnings.simplefilter('always')
>>> np.testing.assert_array_equal([['a', 'b'], ['c']], [['a', 'b'], ['c']])
/home/larsoner/python/numpy/numpy/testing/_private/utils.py:709: DeprecationWarning: Creating an ndarray with automatic object dtype is deprecated, use dtype=object if you intended it, otherwise specify an exact dtype
x = array(x, copy=False, subok=True)
/home/larsoner/python/numpy/numpy/testing/_private/utils.py:710: DeprecationWarning: Creating an ndarray with automatic object dtype is deprecated, use dtype=object if you intended it, otherwise specify an exact dtype
y = array(y, copy=False, subok=True)
For projects that use warnings-as-errors in CIs, assert_array_equal on things that get cast to object arrays is now problematic. There might be other members of np.testing with a similar issue.
Perhaps assert_array_equal should make use of the warning-catching suggested in #15047, but the non-thread-safeness of catch_warnings makes me a bit wary of this solution.
Metadata
Metadata
Assignees
Labels
No labels