[Numpy-discussion] What is the different between nanmin and min ?

Robert Kern robert.kern@gmail....
Thu Jul 19 00:39:17 CDT 2007


Timothy Hochberg wrote:
> 
> On 7/18/07, *Robert Kern* <robert.kern@gmail.com
> <mailto:robert.kern@gmail.com>> wrote:
> 
>     Timothy Hochberg wrote:
> 
>     > The time is one issue. Another is that ignoring NaNs is only
>     correct if
>     > you are treating NaNs as missing values. If instead you are treating
>     > them as non numbers, the results of some bogus computation, then
>     raising
>     > an error is a more appropriate response. If one was going to take the
>     > time to check for NaNs, one strategy that I would probably support
>     would
>     > be to ignore the NaNs, but set the invalid flag. If the error
>     state for
>     > invalid was set to ignore, then this would work as the missing value
>     > camp likes, otherwise it would raise an error or signal a warning.
> 
>     I'd almost be willing to make max() and min() always ignore quiet
>     NaNs. The C99
>     standard requires this, for example, (c.f. section F.9.9.2 of the
>     C99 standard).
> 
> Wow! It sure does. That surprises me as it seems antithetical to my
> understanding of the concept of NaNs being non comparable. Perhaps my
> understanding is just flawed, it wouldn't be the first time. Personally,
> I'd still rather see the warning get set when NaNs are around. That's
> colored by my usage patterns where if a NaN is present, it's a problem
> and I'd like to know about sooner rather than later.

Well, the IEEE-754 standard is silent, to my reading, on "min" and "max". It's
also silent on what wily programmers can do with isnan(), and that's essentially
what the C99 standard is specifying: using isnan() to special-case the result of
fmin() and fmax(). The operations that IEEE-754 specifies (> and <) are just not
being used in the presence of NaNs.

Of course, if C99 is free to do whatever the hell they want, so are we.  :-)

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco


More information about the Numpy-discussion mailing list