[NumPy-Tickets] [NumPy] #1720: logical_and () handles nan incorrectly
NumPy Trac
numpy-tickets@scipy....
Mon Jan 24 13:51:16 CST 2011
#1720: logical_and () handles nan incorrectly
---------------------------+------------------------------------------------
Reporter: joshuaschmitt | Owner: somebody
Type: defect | Status: new
Priority: normal | Milestone: 2.0.0
Component: Other | Version: 1.5.0
Keywords: |
---------------------------+------------------------------------------------
Comment(by pv):
The behavior of `1 and nan` in Python is a language wart: `(1 and foo) is
foo`, for any object `foo`. I don't think there is a reason to make
`logical_and` to follow to this behavior.
The C behavior does not seem to be specified: at least the C99 standard
does not say anything about the truth value of NaNs. Conversion from NaN
to integers is explicitly undefined, and I'd suppose the same applies
booleans. The `if` statement OTOH is defined via:
> The first substatement is executed if the expression compares unequal to
0.
In the else form, the second substatement is executed if the expression
compares equal to 0.
`gcc` apparently implements the first check: the truth value of NaN is
False in this context (because NaN is not unequal to 0). Assuming that the
truth value is `True` would however make as much sense.
--
Ticket URL: <http://projects.scipy.org/numpy/ticket/1720#comment:3>
NumPy <http://projects.scipy.org/numpy>
My example project
More information about the NumPy-Tickets
mailing list