-
-
Notifications
You must be signed in to change notification settings - Fork 12k
Closed
Description
Reproducing code example:
With NumPy 1.21:
>>> import numpy as np
>>> x = np.zeros((3,), np.void)
>>> x == x
/usr/local/lib/python3.7/dist-packages/ipykernel_launcher.py:4: FutureWarning: elementwise == comparison failed and returning scalar instead; this will raise an error or perform elementwise comparison in the future.
False
I believe the error comes from these lines:
numpy/numpy/core/src/multiarray/arrayobject.c
Lines 1361 to 1375 in 1581032
| _res = PyArray_CanCastTypeTo(PyArray_DESCR(self), | |
| PyArray_DESCR(array_other), | |
| NPY_EQUIV_CASTING); | |
| if (_res == 0) { | |
| /* 2015-05-07, 1.10 */ | |
| Py_DECREF(array_other); | |
| if (DEPRECATE_FUTUREWARNING( | |
| "elementwise == comparison failed and returning scalar " | |
| "instead; this will raise an error or perform " | |
| "elementwise comparison in the future.") < 0) { | |
| return NULL; | |
| } | |
| Py_INCREF(Py_False); | |
| return Py_False; | |
| } |
On NumPy 1.20, the output is correct:
array([ True, True, True])
Or conversely, if we use a non-zero length void dtype, e.g.,
>>> x = np.array([b'foo', b'bar'], np.void)
>>> x == x
array([ True, True])
Metadata
Metadata
Assignees
Labels
No labels