-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
DEP: do not deprecate the trapezoidal rule #25586
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
Comments
Thanks @ntessore for opening this discussion. Given the usage frequency, I agree this would be somewhat disruptive. The current state is:
An alternative is to keep it but rename it. For the majority of usage I think it's the same, since most projects and end user code is already going to rely on I'm not opposed to adding Let's see what others think. |
Thanks for your reply @rgommers. Let me address the one point that I can:
I use the trapezoidal rule as my go-to because the only generic assumption that I am willing to make about sampled data is that it is sampled finely enough for a piecewise linear approximation to be "good enough". The trapezoidal rule implements this assumption, while anything beyond that is, in some sense, "augmentation" of the data. In my work, I am usually integrating data I have sampled myself, and it is hence usually always possible for me to push the sampling into that "linear is good enough" regime. There other reasons for choosing the trapezoidal rule (e.g. when the given data needs resampling, and the piecewise linear approximation allows you find additional sampling points without changing the result of the quadrature), and there are reasons when the trapezoidal rule is actually the method of choice (some oscillatory integrals). I don't think these "informed choices" are reasons to keep the function around. Instead, I would argue firmly along the lines of: here is a simple quadrature method that makes the minimal amount of assumptions about the data, and in many (most?) cases its error can be pushed below any desired tolerance. |
In particular, the dft :) |
Discussed in the community meeting today: we'll put it back in as The error message will mention both |
Thanks for taking the time to consider this issue! |
Rather than pointing users at ``scipy.interpolate.trapezoid``, we keep the functionality in NumPy after the discussion in numpygh-25586. `trapz` stays deprecated, and will be removed in the future. But this change makes the change for users who don't want to depend on SciPy a lot easier. [skip cirrus]
Rather than pointing users at ``scipy.interpolate.trapezoid``, we keep the functionality in NumPy after the discussion in numpygh-25586. `trapz` stays deprecated, and will be removed in the future. But this change makes the change for users who don't want to depend on SciPy a lot easier. Closes numpygh-25586 [skip cirrus]
Rather than pointing users at ``scipy.interpolate.trapezoid``, we keep the functionality in NumPy after the discussion in numpygh-25586. `trapz` stays deprecated, and will be removed in the future. But this change makes the change for users who don't want to depend on SciPy a lot easier. Closes numpygh-25586 [skip cirrus]
Proposed new feature or change:
I would like to ask you to reconsider the planned removal of the trapezoidal rule (currently
trapz()
, but see below about the name) in numpy v2, in favour of the equivalent in SciPy.While
trapz()
is perhaps not in the first tier of numpy functions, it is not exactly rare, withnp.trapz
showing up around 20k times in a GitHub code search. Its implementation is a very simple pure Python function with an exceedingly stable interface, and I cannot imagine it is much of a maintenance burden.While the functionality could be out-sourced to SciPy, the requirements for SciPy far exceed those of Numpy, and for a project not already using SciPy, it arguably makes more sense to copy and paste Numpy's soon-to-be-deprecated implementation than to add the quite heavy dependency on SciPy.
I understand that there has initially been an objection to the
trapz()
name, on the basis of derogatory connotations. Not being part of the affected group, I do not have an opinion on the name. But perhaps it would suffice to deprecate the old name in favour of a new one for the existing function, which would still be far less disruptive than complete removal of the functionality.The text was updated successfully, but these errors were encountered: