[Numpy-discussion] np.sign and object comparisons

Stephan Hoyer shoyer at gmail.com
Mon Aug 31 13:23:10 EDT 2015


On Mon, Aug 31, 2015 at 1:23 AM, Sebastian Berg <sebastian at sipsolutions.net>
wrote:

> That would be my gut feeling as well. Returning `NaN` could also make
> sense, but I guess we run into problems since we do not know the input
> type. So `None` seems like the only option here I can think of right
> now.
>

My inclination is that return NaN would be the appropriate choice. It's
certainly consistent with the behavior for float dtypes -- my expectation
for object dtype behavior is that it works exactly like applying the
np.sign ufunc to each element of the array individually.

On the other hand, I suppose there are other ways in which an object can
fail all those comparisons (e.g., NaT?), so I suppose we could return None.
But it would still be a weird outcome for the most common case. Ideally, I
suppose, np.sign would return an array with int-NA dtype, but that's a
whole different can of worms...

Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150831/1dc1a7aa/attachment.html>


More information about the NumPy-Discussion mailing list