[Numpy-discussion] numpy.sign(numpy.nan)?????

Robert Kern robert.kern at gmail.com
Fri May 16 14:23:55 EDT 2008


On Fri, May 16, 2008 at 11:23 AM, Stuart Brorson <sdb at cloud9.net> wrote:
> Hi guys,
>
> Just a quick note.  I've been playing with NumPy again, looking at
> corner cases of function evaluation.  I noticed this:
>
> In [66]: numpy.sign(numpy.nan)
> Out[66]: 0.0
>
> IMO, the output should be NaN, not zero.
>
> If you agree, then I'll be happy to file a bug in the NumPy tracker.
> Or if somebody feels like pointing me to the place where this is
> implemented, I can submit a patch.  (I grepped through the source for
> "sign" to see if I could figure it out, but it occurs so frequently
> that it will take longer than 5 min to sort it all out.)
>
> Before I did anything, however, I thought I would solicit the opinions
> of other folks in the NumPy community about the proper behavior of
> numpy.sign(numpy.nan).

You're probably right. I would like to see what other systems do
before changing it, though.

The implementation is actually in a #define macro in
umathmodule.c.src. Look for _SIGN1 (and _SIGNC if you want to clean up
the complex versions, too).

-- 
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