[Numpy-discussion] comparing arrays with NaN in them.
Christopher Barker
Chris.Barker at noaa.gov
Fri Aug 24 12:53:51 EDT 2007
Timothy Hochberg wrote:
> in principle it's not safe to rely on NaNs being bitwise equal.
Thanks Tim, I always learn a lot on this list.
Anyway, I think my suggestion of "binary equal" wasn't really what I
want. What I want is essentially a NaN-safe comparison, much like the
NaN-safe functions like nanmax, nanmin, etc.
I guess what that would involve is looping through the arrays, checking
for "==", then checking if both are NaN if it returns false. (or
checking for the NaN's first).
I'm not sure NaNifying the other comparisons would make any sense: NaN >
NaN (and all the other comparison's would have to return False anyway.
So, would a nanequal function be useful? would it be hard to write?
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the NumPy-Discussion
mailing list