To know the elements of a numpy array that verifies two conditions, one can use the operator *:
>>> a = np.array([[1,10,2],[2,-6,8]])
>>> a
array([[ 1, 10, 7],
[ 2, -6, 8]])
>>> (a <= 6) * (a%2 == 0) # elements that are even AND inferior or equal to 6
array([[False, False, False],
[ True, True, False]], dtype=bool)
But how about OR? I tried to do this:
>>> (a%2 == 0) + (a <= 6) - (a%2 == 0) * (a <= 6)
array([[ True, True, False],
[False, False, True]], dtype=bool)
but the result is false for the elements that verifies both conditions. I don't understand why.
&for and,|for or,^for xor and~for not.