-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
BUG: in1d fails when second argument is empty. #21841
Copy link
Copy link
Closed
Description
Describe the issue:
Here's an example that demonstrates the problem; note that ar2 has length 0:
In [16]: np.__version__
Out[16]: '1.24.0.dev0+361.g3039cd3a9'
In [17]: ar1 = np.array([0, 1])
In [18]: ar2 = np.array([], dtype=np.int64)
In [19]: np.in1d(ar1, ar2)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-19-8fa615713ba7> in <cell line: 1>()
----> 1 np.in1d(ar1, ar2)
~/py3.10.1/lib/python3.10/site-packages/numpy/core/overrides.py in in1d(*args, **kwargs)
~/py3.10.1/lib/python3.10/site-packages/numpy/lib/arraysetops.py in in1d(ar1, ar2, assume_unique, invert, kind)
637
638 if integer_arrays and kind in {None, 'table'}:
--> 639 ar2_min = np.min(ar2)
640 ar2_max = np.max(ar2)
641
~/py3.10.1/lib/python3.10/site-packages/numpy/core/overrides.py in amin(*args, **kwargs)
~/py3.10.1/lib/python3.10/site-packages/numpy/core/fromnumeric.py in amin(a, axis, out, keepdims, initial, where)
2916 6
2917 """
-> 2918 return _wrapreduction(a, np.minimum, 'min', axis, None, out,
2919 keepdims=keepdims, initial=initial, where=where)
2920
~/py3.10.1/lib/python3.10/site-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
84 return reduction(axis=axis, out=out, **passkwargs)
85
---> 86 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
87
88
ValueError: zero-size array to reduction operation minimum which has no identity
This breaks of bunch of SciPy tests.
NumPy/Python version information:
1.24.0.dev0+361.g3039cd3a9 3.10.1 (main, Jan 14 2022, 02:27:20) [GCC 11.2.0]
Reactions are currently unavailable