[Numpy-discussion] ndarray with double comparison
Sat Oct 15 06:05:14 CDT 2011
Marc Shivers <marc.shivers <at> gmail.com> writes:
> you could use bitwise comparison with paretheses: In : (a>4)&(a<8)Out:
array([False, False, False, False, False, True, True, True, False,
False, False], dtype=bool)
For cases like this I find it very useful to define a function between() - e.g.
Then you can use
between(a, 4, 8)
(4 < a) & (a < 8),
which I find less readable and more difficult to type.
More information about the NumPy-Discussion