-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
MAINT: Remove np.in1d and np.trapz usages #27140
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
ade66be
to
451dbea
Compare
Hi! As numpy/numpy#24445 will be merged soon, would there be a chance for a review? |
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 @mtsokol. I'd recommend a tweak to the trapezoid imports. Other than that it looks good to me.
@@ -2,6 +2,7 @@ | |||
|
|||
import numpy as np | |||
import pytest | |||
from scipy.integrate import trapz as trapezoid |
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.
The preferred name in scipy has been trapezoid
since 1.6.0, so you should probably try-import that first, and only use import trapz
as a fallback with a note that the fallback can be removed if 1.6.0 becomes the minimum supported scipy version (it's 1.5.0 now).
We'll remove trapz
at some point, so this would be more future-proof.
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.
That's clear - I added try except
for all three imports.
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 for coming along to fix things that will be broken :)
I think the changes looks reasonable.
Is there a reason to be in a hurry with merging this? It looks like the PR hasn't been merged yet. And once it has been merged it will take a moment to trickle through to the CI run against the nightlies
You're testing against numpy nightlies, so merging the fixes before the breaking numpy nightly arrives is always useful. We try to be careful in numpy to not merge things that we can see are going to break CI for scikit-learn or another project, but we won't wait for weeks. |
0a406d6
to
e522e01
Compare
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.
LGTM now
This change was merged into numpy's main branch just now. I recommend hitting the green button here. |
Thanks a lot for the PR:
|
Thanks a lot for the PR, merging this one! Not too sure about the coverage drop and why it only appears in the last commit and not previously so I am going to ignore it. I did test manually this code branch and it seems fine. |
Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
Hi!
This PR changes
np.in1d
calls tonp.isin
asnp.in1d
is being made private in numpy/numpy#24445.In three cases I wasn't sure if arrays passed to it are surely 1d (so higher dimensional), therefore I called
.ravel()
to fully reproduce in1d behavior.If any of these lines actually operate on 1d arrays, then isin and in1d can be used interchangeably.
Also
np.trapz
is removed in favor ofscipy.interpolate.trapezoid
(same implementation).