[Numpy-discussion] Sign of NaN
Charles R Harris
charlesr.harris at gmail.com
Tue Sep 29 14:53:08 EDT 2015
On Tue, Sep 29, 2015 at 12:16 PM, Nathaniel Smith <njs at pobox.com> wrote:
> On Sep 29, 2015 8:25 AM, "Anne Archibald" <archibald at astron.nl> wrote:
> >
> > IEEE 754 has signum(NaN)->NaN. So does np.sign on floating-point arrays.
> Why should it be different for object arrays?
>
> The argument for doing it this way would be that arbitrary python objects
> don't have a sign, and the natural way to implement something like
> np.sign's semantics using only the "object" interface is
>
> if obj < 0:
> return -1
> elif obj > 0:
> return 1
> elif obj == 0:
> return 0
> else:
> raise
>
That is what current master does, using PyObject_RichCompareBool for the
comparisons.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150929/59d86a33/attachment.html>
More information about the NumPy-Discussion
mailing list