# Numpy is absurd

I always gripe about Python not having built-in array type and Numpy doesn't distinguish "vector of vector" from "matrix", but this still surprised me.

## `in` is actually `intersect`?

It seems that Numpy uses `intersect` logic to check `a in b`:

``````In : import numpy as np

In : np.__version__
Out: '1.23.1'

In : np.array() in np.array([1,2,3])
Out: True

In : np.array([1,2,3]) in np.array()
Out: True``````

also it doesn't care about `dtype` at all, so it's `intersect` but with value comparison:

``````In : np.array([1,2,3,4,5]) in np.array([2.0])
Out: True

In : float(1) in np.array([1,2,3,4,5])
Out: True``````

## `in` is actually `intersect(a.flat, b.flat)`?

Things only get weired when we go to higher dimensional array:

``````In : 2 in np.array([[1,2], [3, 4]])
Out: True

In :  in np.array([[1,2], [3, 4]])
Out: True

In : [] in np.array([[1,2], [3, 4]])
Out: True

In : [[]] in np.array([[1,2], [3, 4]])
Out: True

In : np.array([[]]) in np.array([[1,2], [3, 4]])
Out: True``````

Furthur more, because `intersect` is commutitive, `in` is also commutitive!

``````In : np.array([[1,2], [3, 4]]) in np.array()
Out: True``````

## Wait, wtf

Finally, just when you throught you understand what Numpy is doing, it seems there's special treatment for `ndarray` of `len() == 1`

``````In : np.array([1,2,3]) in np.array()
Out: True

In : np.array([1,2,3]) in np.array([2, 3])
<ipython-input-32-e5b43569579c>:1: DeprecationWarning: elementwise comparison failed; this will raise an error in the future.
np.array([1,2,3]) in np.array([2, 3])
Out: False``````

But then what is this?

``````In : np.array([99,2,123]) in np.array([2, 30, 50])
Out: False

In : np.array([99,2,123]) in np.array([2, 123, 50])
Out: False

In : np.array([99,2,123]) in np.array([99, 123, 50])
Out: True``````