[Numpy-discussion] What is the logical value of nan?
Christopher Barker
Chris.Barker at noaa.gov
Wed Mar 11 13:06:52 EDT 2009
Sturla Molden wrote:
> Why not raise an exception when NaN is evaluated in a boolean
> context? bool(NaN) has no obvious interpretation, so it should be
> considered an error.
+1
Though there is clearly a lot of legacy around this, so maybe it's best
to follow C convention (sigh).
Bruce Southey wrote:
> Also, I think that conversion to an integer should be an error for
> all of these because there is no equivalent representation of these
> floating point numbers as integers and I think that using zero for
> NaN is wrong.
+1
A silent wrong conversion is MUCH worse than an exception!
As for MATLAB, it was entirely doubles for a long time -- I don't think
it's a good example of well thought-out float<->integer interactions.
> Now for the other two special representations, I would presume that
> Numpy's PZERO (positive zero) and NZERO (negative zero) are treated
> as nothing. Conversion to integer for these should be zero.
+1
> Note this defines the min/max behavior:
>
> * |min(x,NaN) = min(NaN,x) = x| * |max(x,NaN) = max(NaN,x) = x|
nice -- it's nice to have these defined -- of course, who knows how long
it will be (never?) before compilers/libraries support this.
-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