[Numpy-discussion] precedence of '&' and '>' operators
Michael Sorich
michael.sorich at gmail.com
Mon Mar 27 16:17:13 CST 2006
It seems that the '&' operator has a higher precedence than a comparison
operator such as '>'. This does not seem so intuitive to me. Is this
correct?
eg
>>>import numpy as N
>>>N.version.version
'0.9.6'
>>>a = N.arange(10)
>>>a>1 & a<4
Traceback (most recent call last):
File "<input>", line 1, in ?
ValueError: The truth value of an array with more than one element is
ambiguous. Use a.any() or a.all()
>>>(a>1) & (a<4)
array([False, False, True, True, False, False, False, False, False, False],
dtype=bool)
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060327/92b9f482/attachment.html
More information about the Numpy-discussion
mailing list