[Numpy-discussion] logical priority
Stephen Walton
stephen.walton at csun.edu
Mon Feb 7 13:59:33 EST 2005
A probably bonehead question: is it a known feature of Python that, in
a logical operation, & has a higher priority than > or < ? Or is it a
quirk of numarray?
In [126]: a = arange(25)
In [127]: v=(a>9) & (a<13)
In [128]: v=a>9 & a<13
---------------------------------------------------------------------------
exceptions.RuntimeError Traceback (most
recent call last)
/home/swalton/research/foukal/<console>
/usr/lib/python2.3/site-packages/numarray/generic.py in __nonzero__(self)
475
476 def __nonzero__(self):
--> 477 raise RuntimeError("An array doesn't make sense as a
truth value. Use any(a) or all(a).")
478
479 def __copy__(self):
RuntimeError: An array doesn't make sense as a truth value. Use any(a)
or all(a).
More information about the NumPy-Discussion
mailing list