>>> np.any((0 < x) & (x < 1)) True
What x.any() really does: this is the same as np.any(x) , i.e. returns True if any elements from x are nonzero. So, your comparison is 0 < True < 1 , which is wrong, because in python 2 0 < True true, but True < 1 not, since True == 1 .
In this approach, in contrast, we create logical arrays of whether the comparison is true for each element, and then check whether any element of this array is true:
>>> 0 < x array([[ True, False, False], [False, True, True], [False, False, True]], dtype=bool) >>> x < 1 array([[False, True, True], [ True, False, True], [ True, True, False]], dtype=bool) >>> (0 < x) & (x < 1) array([[False, False, False], [False, False, True], [False, False, False]], dtype=bool)
You have to do explicit & , because, unfortunately, numpy does not (and I think I can not) work with the built-in chain of python operators of comparison operators.