-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
BUG: Fix numpy.isin for timedelta dtype #21860
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, I would lean towards using a .dtype.kind
check, although that may require an update to not use in "ui?"
, but in ("u", "i", "?")
for new dtypes soon...
One potential issue: However, this never ends up happening in practice, since |
Actually, it could happen, if ar1 is a bool and ar2 an integer array. ar2 could be over the range limit, and then ar1 will get converted to a |
Its fine, but it would be great if you could make sure we have tests "documenting" how these are expected to behave (parameterizing the methods again ideally). |
Sounds good. Just so I understand, is |
It does not matter right now. We just make the test pass with whatever behavior current (or previous) NumPy had. If you think it should maybe fail, add a comment to that effect. But the day where this fails is probably also the day where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, going to apply those tweaks and merge in a bit. Especially thanks for adding those tests. More tests area always good, and now looking at it tests e.g. for datetime arrays with NaT
might be nice (OTOH, those should be fine, since they use sorting/unique, which in turn should be fine!)
This is probably really mainly my personal opinion...
This PR fixes the issue discussed on #12065 and #21843 where
'timedelta64'
was noted to be a subtype ofnumpy.integer
. This in principle should detect any cases whereint(np.min(ar2))
fails. This PR also adds unittests for these.@seberg @adeak could one of you have a look at this?
Thanks,
Miles