Skip to content

Conversation

devmt04
Copy link

@devmt04 devmt04 commented Aug 4, 2025

BUG FIX : #29496

Added the support for handling special NaT values in np.sign(), for consistency with the behavior of the inexact types. Earlier np.sign(np.timedelta64('nat')) was returning timedelta64(-1) and for consistency with the behavior of the inexact types (e.g. np.sign(np.nan) returns np.float64(nan)), it should return timedelta64('nat'). After committing this change, it successfully returns timedelta64('nat') on np.timedelta64('nat') inputs.

Previously :

In [2]: np.sign(np.timedelta64('nat'))
Out[2]: np.timedelta64(-1)

After this fix :

In [3]: np.sign(np.timedelta64('nat'))
Out[3]: np.timedelta64('NaT')

This change aligns the behavior with expectations for inexact types and addresses issue #29496.

@WarrenWeckesser
Copy link
Member

Thanks @devmt04, but did you notice that I already submitted a fix for this issue in #29498 three days ago? I mentioned this in a comment in #29496, and github itself shows a link to the pull request in that issue.

@tylerjereddy tylerjereddy added the 57 - Close? Issues which may be closable unless discussion continued label Aug 5, 2025
@tylerjereddy
Copy link
Contributor

I propose that we close this one in favor of gh-29498, since the other PR came first and already has a regression test.

The patches are small enough that it shouldn't be too much of an inconvenience in any case.

@devmt04
Copy link
Author

devmt04 commented Aug 5, 2025

did you notice that I already submitted a fix for this issue in #29498 three days ago?

I am really sorry for this, since this was my first ever contribution in open-source, i was unaware about the PR you already raised for the same issue. Hope you understand.

@devmt04 devmt04 closed this Aug 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 57 - Close? Issues which may be closable unless discussion continued
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: sign(timedelta64('nat')) returns -1; expected timedelta64('nat')
3 participants