# Np.array([1,0]) in np.array([[1,1]]) == True?

Is this a bug?

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

``````

or, by parts

``````In : a = np.array([[0,0]])

In : b = np.array([1,0])

In : b in a
Out: True

``````

According to this reply the `in` operator is meaningful only if the first operand is scalar:

Another interesting question:

2 Likes

Unfortunate, but thanks Out of curiosity, what is the source data? That is, what do these return?

``````print(np.array([1,0]))

print(np.array([[1,1]]))
``````
1 Like

None really, I was just learning the syntax, thus:

``````In : print(np.array([1,0]))
[1 0]

In : print(np.array([[1,1]]))
[[1 1]]

``````

by the way, it is also slightly confusing that the output format of the array is not consistent with the input:

``````In : a = np.array([[0, 0]])

In : for v in a :
...:     print(v)
...:
[0 0]

In : [0 0] in a
File "<ipython-input-7-86c19ca29a5c>", line 1
[0 0] in a
^
SyntaxError: invalid syntax

``````

Try `repr()`. I am not sure how it is implemented in NumPy arrays but it is designed to get a consistent representation of objects.

``````for v in a:
print(repr(v))
print(f'{v!r}')    # shorthand for repr() inside formatted string
``````
2 Likes