-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
API: Cleaning numpy/__init__.py
and main namespace - Part 4 [NEP 52]
#24445
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
API: Cleaning numpy/__init__.py
and main namespace - Part 4 [NEP 52]
#24445
Conversation
b812dfd
to
35e072c
Compare
numpy/__init__.py
and main namespace - Part 4 [NEP 52]
fea696e
to
f9fd36d
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.
Overall looks great, just a couple comments.
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. I see scipy/scipy#19100 got merged, are there other downstream PRs we should wait to get merged before this does?
There are still usages of them in SciPy and Pandas, I will create PRs shortly. [EDIT] Done for Pandas, SciPy and scikit-learn. For matplotlib a draft PR was already created. |
* replace deprecated `in1d` with `isin` calls per numpy/numpy#24445, as part of effort to remain NumPy `2.0` compliant * the testsuite seems happy locally--if there are any cases where `in1d` was potentially receiving arrays with `ndim > 1`, we may want to add `ravel()` to the outputs in these replacements just to be safe, but I've assumed the testsuite has us covered * for now, I've intentionally not adjusted the docstring of our Cython `_in2d`, which refers to `in1d`; seems less critical for now
bebb3a2
to
732e6d5
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.
The diff seems sensible to be me as well (there was some desire for a non-Quansight reviewer as well in last meeting).
I did wonder a little bit about whether it makes sense to delete the tests for i.e., trapz
before the function is completely removed vs. suppressing the deprecation warnings on those tests until trapz
disappears for good.
Downstream reception to the patches seems "ok" enough. I also opened a cross-listed PR to NumFOCUS project MDAnalysis and they seemed alright with it as well.
* MAINT: in1d -> isin * replace deprecated `in1d` with `isin` calls per numpy/numpy#24445, as part of effort to remain NumPy `2.0` compliant * the testsuite seems happy locally--if there are any cases where `in1d` was potentially receiving arrays with `ndim > 1`, we may want to add `ravel()` to the outputs in these replacements just to be safe, but I've assumed the testsuite has us covered * for now, I've intentionally not adjusted the docstring of our Cython `_in2d`, which refers to `in1d`; seems less critical for now * DOC: PR 4255 revisions * add an appropriate `CHANGELOG` entry per reviewer request * Update package/CHANGELOG --------- Co-authored-by: Oliver Beckstein <orbeckst@gmail.com>
48ca8f8
to
448dd0d
Compare
@tylerjereddy I can reintroduce |
0dfc32f
to
41639e4
Compare
I think keeping the tests for deprecated code around is worthwhile, the marginal cost of running a unit test is low and it's possible superficially unrelated code changes could break deprecated functionality and it would be nice to be aware of that. |
Makes sense to me - I reintroduced |
41f19fa
to
c60bdc6
Compare
2bb6fcd
to
4f5b772
Compare
@mtsokol would you mind fixing the merge conflict? |
4f5b772
to
bf91c88
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, this has been in the queue for 2 weeks, and it looks solid. In it goes, thanks @mtsokol!
@@ -4880,6 +4883,14 @@ def trapz(y, x=None, dx=1.0, axis=-1): | |||
>>> np.trapz(a, axis=1) | |||
array([2., 8.]) | |||
""" | |||
|
|||
# Deprecated in NumPy 2.0, 2023-08-18 | |||
warnings.warn( |
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.
This will affect a lot of analysis code... not just developers, but users.
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.
FWIW, we did that same rename in scipy.integrate
a few years ago, and got no complaints. This name is considered a slur, and that's an extra reason to get rid of it. We touched on this in the 2.0 dev call IIRC, and folks were in favor of names that are both more descriptive and more inclusive (cumsum
& co too).
It's deprecated rather than outright removed here exactly because it's used quite a bit. So no code will actually break in the 2.0 release.
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.
Huh, didn't know it's a slur. Thanks for the clarification!
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.
Neither did I until scipy/scipy#12924.
Never heard/read it myself. Lots of things can become slurs when it is convenient. |
I don't know which issue, or even venue, is appropriate for this, but can I please register the strongest possible objection to removing the trapezoidal rule entirely from numpy, and relying on scipy? It is such a fundamental and common operation, that it would be an immense downside having to depend on scipy just for this. |
@ntessore could you please open a new issue instead? That way it's easier to discover and discuss. Expanding a little on the impact would be useful too (e.g., number of places it's used which don't already depend on SciPy). |
This PR adds back the links that were removed from `trapz` in PR numpy#24445, finishing the migration to `trapezoid` in PR numpy#25738. Currently, no web docs appear for `trapezoid`.
This PR adds back the links that were removed from `trapz` in PR numpy#24445, finishing the migration to `trapezoid` in PR numpy#25738. Currently, no web docs appear for `trapezoid`. [skip actions] [skip azp] [skip cirrus]
Follow-up PR after #24376 is merged.Can be merged independently.Relevant issue: #24306.
Scope of the PR:
row_stack
(an alias forvstack
) to be removed completely in 2.0trapz
in favor ofscipy.interpolate.trapezoid
(scipy
usestrapz
implementation, therefore it must be moved there)in1d
(instead useisin
) and makein1d
private in 2.0