-
-
Notifications
You must be signed in to change notification settings - Fork 5k
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
DEP: integrate: deprecate romberg and quadrature #19510
Conversation
I don't think there's a like to like equivalence for the replacement function. For example, I have a use case that requires adaptive quadrature. However, I want to start at an order of 20 and work upwards. I don't think I could do that with |
Even without a use case, I think these still would still have value as reference implementations for classic algorithms. |
@ev-br indicated +1 for deprecation. Could we deprecate, but not remove? |
I’d be ok with that. I think @mdhaber’s right that most users probably would be better served by using quad, and the deprecation warning could point them in the right direction. Someone who has a specific reason to use Romberg integration or Gaussian quadrature would still have the option at least and could just silence the warning. |
I would be -1 on deprecating but not removing. It creates confusion and the warnings are just annoying. Instead can we not just add a warning to the docs saying in most cases you would be better served by xyz.
I have to admit personally I do not think this is hugely valuable, most guass quadrature methods are trivial to implement given the collection of orthogonal polynomials in special. Plus there are other classics we are missing eg. other than the interface to quadpack we don't have a Clenshaw–Curtis implementation. |
Another option is to declare them "legacy". It has been suggested that "legacy" code would not be maintained and would be released once as a separate package alongside SciPy 2.0, from which it would be removed. Documentation would steer new users away from legacy functions, but I don't think legacy code would emit a warning until a SciPy 2.0 is planned. @h-vetinari and I had discussed reclaiming the name I could live with declaring these as That said, I would be surprised if there are many |
Is it possible to add new keywords to |
Also, I saw in your benchmarks above that
Why not rename |
Right, they just give incorrect output and the user doesn't know, so they don't report an error : )
The output is currently a NumPy float. We could add the error as an attribute (something I would actually like), but I get the impression that this would not be popular. So adding an error estimate would probably mean adding a keyword argument that changes the return type, and that's something we're trying to get away from.
That's always a possibility. I just prefer to trim it because I think there are better alternatives available.
Perhaps it would be possible when QUADPACK gets translated. I think @ilayn was interested in that eventually? |
I see. Having I think my preference would be to keep it around, but with the error estimates, and with documentation clearly stating the limitations of the method, and the situations where it may actually be useful. |
Yes, intention is no unmaintained F77 code eventually. But I'd be really happy to not to translate if things are already not up to production level. Already feeling dizzy from cross referencing cryptic hieroglyphs. There is no point providing low-quality options to the users. If needed, anyone can download from Netlib and use it. Or alternatively we can leave it in a separate package as is. Hence my vote is going for writing a bit of meson magic on top of things we deprecate and separate, so the legacy stuff is still pip installable and but leaving everything in the past like we did with This is all contingent upon having a better alternative of course. |
Oops @ilayn Fortran |
It seems like the only objection is to deprecating EDIT: |
Then I don't know what I'm talking about 😃 so yes, at some point we will translate and for the rest I shut up. |
With the help of Matt I've just been investigating the use of _tanhsinh for some of my personal projects. It's clear that that approach and indeed |
I have no real objections to deprecating both since that seems to the consensus. I just want to make sure everyone’s aware that the benchmark set from #18574 (comment) contains examples which violate the assumptions of Romberg integration, e.g. singularities, points that evaluate to |
Thanks @andyfaff!
@j-bowhay I think @steppi had reservations about removing the Romberg algorithm, although IIUC @steppi you would be OK deprecating if the algorithm were made available otherwise? I thought about a possible compromise.
This might work, but I see a few issues:
Personally, I'd prefer a clean break, and once |
I think I’m fine with the clean break then. There’d be opportunity cost with the extra work required. The effort would probably be better spent elsewhere. |
As a aside: is there a write-up somewhere about interface differences/ target use cases of tanhsinh vs quad_vec? |
Not yet. Depending on how you write the callable, you can do integrals of vector-valued functions with In any case, I plan to get rid of this limitations of |
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.
Think this is needed (as well as the fix in main) for the doc build
Thanks @j-bowhay. I merged main and added your suggestions: |
[skip actions] [skip cirrus]
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, happy to merge if that is the general consensus
I just wanted to express (as a user) my strong opposition to removing algorithms, exactly per @steppi's original comment:
I'm sure at some point in the future I will use them, whether for sanity checks or teaching purposes. I love the direction to unify the quadrature interfaces (and add better algorithms) - does that have to come at the cost of dropping other, already-implemented methods? Even if making Romberg and fixed-tol Gaussian options for the future interface is not feasible, why not just keep the old functions, sans deprecation (even if |
@j-bowhay @steppi @andyfaff I added
|
Sorry @zachjweiner, but I've had to revert back to deprecation due to feedback from the mailing list. These functions will always be available in the SciPy source for reference - git never erases anything from the history - and the plan is to replace them with better versions of themselves. You have them in the released SciPy for the next two versions, and they are short enough to copy-paste into your own code. @j-bowhay I think this is back to the state of 5baf2f2 in which you approved it. I've seen support for this deprecation from six maintainers, which is more than we ever get, so I'd be happy with merging when tests pass. |
Sounds good. @zachjweiner I think your concern would partially be addressed by the example for special.roots_legendre which shows how to write a simple code for guass quadrature |
I got the opposite impression from the above discussion - that the plan was to drop the algorithms permanently rather than to reimplement them in a new interface - apologies if my perspective was misinformed! My opposition was only to reducing the number of implemented algorithms (I'm generally amenable to adapting personal code to API changes), and I thought keeping the old methods hanging around with whatever names would be the least burdensome way to avoid doing so. I appreciate the consideration either way. |
Reference issue
Toward gh-18574
What does this implement/fix?
scipy.integrate.quadrature
andscipy.integrate.romberg
do not reliably meet the accuracy target and are often slower thescipy.integrate.quad
with the defaultvectorized=False
; see #18574 (comment). This PR deprecates them in favor ofscipy.integrate.quad
.Additional information
To do: