I would appreciate if somebody could help me with this (and explaining what's going on).
This works:
>>> from numpy import array
>>> a = array((2, 1))
>>> b = array((3, 3))
>>> l = [a, b]
>>> a in l
True
But this does not:
>>> c = array((2, 1))
>>> c in l
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
The behaviour I would like to replicate is:
>>> x = (2, 1)
>>> y = (3, 3)
>>> l2 = [x, y]
>>> z = (2, 1)
>>> z in l2
True
Note that what above also work with mutable objects:
>>> x = [2, 1]
>>> y = [3, 3]
>>> l2 = [x, y]
>>> z = [2, 1]
>>> z in l2
True
Of course, knowing that:
>>> (a < b).all()
True
I tried (and failed):
>>> (c in l).all()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()