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
Lagrange polynomials and numpy Polynomials #14409
Comments
Yup, it needs to be Want to send a quick PR with a fix @Jebby993 ? |
Thank you @ev-br ,I could try (I'm quite new here on github). |
poly1d is considered legacy and its use in new code is discouraged. This function predates numpy Polynomial, so we cannot just change its return type. All in all, best is to show the recommended usage --- which this example tried to do :-). |
@ev-br can we mark these kind of things to deprecate them slowly? |
Problem is, I don't see a clean transition path. Do you? Just changing the return type is bad; doc notes do not change that; deprecating the whole function and inventing a new one with a different return type feels like an overkill. So my gut feeling is just keep the status quo and improve the documentation for users to show best practices. |
What I mean is that in case of functions that we say are legacy and should not be used in new code, then I would decorate them to raise a deprecation warning for a few release cycle and then delete them... I know we try to not do this, but we could have long cycles to mitigate issues with users. |
For polynomials whose weight functions have compact support, returning a Chebyshev series would be a good idea. There is a |
Yes, but here our function is not deprecated. Instead it's the return type being declared legacy by numpy.
Agreed, it'd be great. Not in scipy.interpolate.lagrange function however I suspect :-). |
To be sure, I am talking about your comment on |
Sure. Chuck @charris , are there any plans w. r. t. |
At some point we have to plan for SciPy 2.0 (just in 2 releases). Such things could be good candidates. |
Nothing planned that I am aware of. The Chebyshev polynomials have the advantage that the coefficients are easy to compute from values sampled at the Chebyshev points, so would work well with the scipy functions that just compute the polynomial values. |
My issue is about the documentation of lagrange interpolation here: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.lagrange.html
lagrange returns a numpy.poly1d that contains "The polynomial’s coefficients, in decreasing powers"
Then, the documentation shows to pass this result to numpy Polynomials. But this class accepts as parameters "Polynomial coefficients in order of increasing degree"
https://numpy.org/doc/stable/reference/generated/numpy.polynomial.polynomial.Polynomial.html
Does it seem like a conceptual error?
Coefficients are the same, but the order is reversed so when you want to interpolate things do not work well
Reproducing code example:
Scipy/Numpy/Python version information:
The text was updated successfully, but these errors were encountered: