I noticed that in
can be used between numpy arrays. However its meaning can be a bit counter-intuitive.
import numpy as np
np.array([0]) in np.array([1, 2])
# False
np.array([0]) in np.array([0, 1])
# True
np.array([0, 1]) in np.array([0])
# True -- somewhat surprisingly
So it seems that it behaves like np.any(np.isin(·, ·))
rather than the somewhat more intuitive np.all(np.isin(·, ·))
.
- Is this really the case?
- What is the rationale behind this choice?