[Numpy-discussion] np.sign and object comparisons

Nathaniel Smith njs at pobox.com
Tue Sep 1 02:45:26 EDT 2015


On Mon, Aug 31, 2015 at 10:31 AM, Antoine Pitrou <solipsis at pitrou.net> wrote:
> On Mon, 31 Aug 2015 10:23:10 -0700
> Stephan Hoyer <shoyer at gmail.com> wrote:
>>
>> 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.
>
> Currently:
>
>>>> np.sign(np.timedelta64('nat'))
> numpy.timedelta64(-1)
>
> ... probably because NaT is -2**63 under the hood. But in this case
> returning NaT would sound better.

I think this is going through the np.sign timedelta64 loop, and thus
is an unrelated issue? It does look like a bug though.

-n

-- 
Nathaniel J. Smith -- http://vorpus.org



More information about the NumPy-Discussion mailing list