0

I naively used a test with this structure, thinking that it was actually checking if a vector is contained in a matrix:

np.array([1,0]) in np.identity(2) #True

But then I discovered that also this is True:

np.array([1,1]) in np.identity(2) #True

Why is python returning True? What is actually being checked? I probably don't understand what in does (and it's hard to google, because "in" is interpreted as a regular preposition)

Ziofil
  • 1,815
  • 1
  • 20
  • 30
  • 1
    See [here](https://stackoverflow.com/questions/7989676/numpy-need-a-hand-in-understanding-what-happens-with-the-in-operator) and [here](https://stackoverflow.com/questions/39452843/in-operator-for-numpy-arrays) – Cory Kramer Jan 12 '18 at 22:46
  • Looks like `in` checks if _any_ element on the right is in the array on the left. I could not find any documented evidence. – DYZ Jan 12 '18 at 22:46

0 Answers0