Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix NaT handling in the PyArray_CompareFunc for datetime and timedelta #19607

Merged
merged 3 commits into from Aug 3, 2021

Conversation

asmeurer
Copy link
Member

@asmeurer asmeurer commented Aug 3, 2021

In #12658 and #15068 the sort ordering for datetime and timedelta was changed
so that NaT sorts to the end, but the internal compare array function was not
updated.

Fixes #19574.

If a test should be added for this, please let me know where.

…edelta

In numpy#12658 and numpy#15068 the sort ordering for datetime and timedelta was changed
so that NaT sorts to the end, but the internal compare array function was not
updated.

Fixes numpy#19574.
numpy/core/src/multiarray/arraytypes.c.src Outdated Show resolved Hide resolved
numpy/core/src/multiarray/arraytypes.c.src Outdated Show resolved Hide resolved
I accidentally based it off the float compare template instead of the integer
compare template. It also now properly handles the case when both arguments
are NaT.
@charris charris merged commit 672a2ec into numpy:main Aug 3, 2021
@charris
Copy link
Member

charris commented Aug 4, 2021

Thanks @asmeurer . This probably maybe could be tested using an object array containing time* types, something like

In [20]: a = array([timedelta64('NaT'), timedelta64(0)], dtype=object)          

In [21]: a.sort() 

But that is hard to check without merging this.

@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Oct 6, 2021
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Oct 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PyArray_CompareFunc of dtype datetime64 returns incorrect value for 'NaT' objects.
2 participants