-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: fix argmin() with NaTs #6031
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
Conversation
np.min() skips NaT values, but np.argmin() wouldn't: since the internal representation of NaT is smaller than every other datetime64 or timedelta64 value, np.argmin() would return results inconsistent with np.min(). Closes numpy#6030.
Since there is a specific code path for it, could we have a test that checks that the argmin is properly calculated when there is a bunch of leading Given the change in behavior, perhaps it is worth a quick note in the release notes as well. |
Funny... that uncovers a bug in np.min() as well:
|
Ok, I've pushed the changes. Should I squash the commits? |
Can we really get rid of the specialized branch for binary reduces? I'd rather keep it, or at least have some timings supporting that the impact to performance is negligible. |
Well, here are some runtimes before the patch:
And after:
|
20% slow down is not negligible, but correctness is sure worth at least that much. And it doesn't seem possible to do things "right" without manually expanding the @charris, @juliantaylor, anyone else: do you have a strong opinion about whether we should squeeze the last drop of performance out of minimum/maximum reduction, or are you OK with reusing the normal elementwise loop for this one case? |
It sounds like that to me as well. |
That seems about enough waiting time, in it goes. Thanks Antoine! |
np.min() skips NaT values, but np.argmin() wouldn't: since the internal
representation of NaT is smaller than every other datetime64 or
timedelta64 value, np.argmin() would return results inconsistent with np.min().
Closes #6030.