Reputation: 8431
For a given 2 dimentional arrays such as below, i need to check if all the elements are less than 0.2.
a = np.array([[0.26002, 0.13918, 0.6008 ],
[0.2997 , 0.28646, 0.41384],
[0.41614, 0.36464, 0.21922]])
Here is my code, based on this question.
res = abs(a<0.2)
all(i==True for i in res)
But the code complains with
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Upvotes: 7
Views: 11784