Skip to content
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

ENH: Non-Legacy Piecewise Linear Interpolation #21258

Closed
maxnoe opened this issue Jul 25, 2024 · 3 comments
Closed

ENH: Non-Legacy Piecewise Linear Interpolation #21258

maxnoe opened this issue Jul 25, 2024 · 3 comments
Labels
enhancement A new feature or improvement scipy.interpolate

Comments

@maxnoe
Copy link
Contributor

maxnoe commented Jul 25, 2024

Is your feature request related to a problem? Please describe.

The interp1d docs state:

This class is considered legacy and will no longer receive updates. This could also mean it will be removed in future SciPy versions. For a guide to the intended replacements for interp1d see 1-D interpolation.

However, the 1D interpolation docs then just point to numpy.interp for piecewise linear interpolation:

If all you need is a linear (a.k.a. broken line) interpolation, you can use the numpy.interp routine. It takes two arrays of data to interpolate, x, and y, and a third array, xnew, of points to evaluate the interpolation on.

However, np.interp is not a replacement for interp1d.

It lacks the equivalent options for the bounding conditions and extrapolation and it always requires sorted input.

It would also make it much easier to compare interpolations using different methods if all would share the same API.

Describe the solution you'd like.

A non-legacy version of interp1d following the same API as the other new classes for piece-wise interpolation.

Describe alternatives you've considered.

No response

Additional context (e.g. screenshots, GIFs)

No response

@maxnoe maxnoe added the enhancement A new feature or improvement label Jul 25, 2024
@ev-br
Copy link
Member

ev-br commented Jul 25, 2024

Note that the dev version has an additional suggestion: https://scipy.github.io/devdocs/tutorial/interpolate/1D.html
Making it more discoverable is definitely in the card, happy to hear suggestions or ---preferably!--- review PRs.

Adding yet another way of doing linear interpolation is not something we would do really.

Legacy code may keep using legacy functions, new code can either keep using interp1d (we do not recommend it, but you can full well not follow the recommendation, it's really up to you), or use what we believe are better alternatives.

@ev-br
Copy link
Member

ev-br commented Jul 25, 2024

Also it looks like we should consider tweaking the wording of the legacy clause. This "may be removed in the future" seems to be misleading.

@ev-br
Copy link
Member

ev-br commented Aug 31, 2024

No follow-up, so I'm going to close this. Thank you @maxnoe for the suggestion regardless!
Documentation improvements are very welcome either way, both for making the "slinear" interpolation more discoverable and for the legacy note wording.

@ev-br ev-br closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement scipy.interpolate
Projects
None yet
Development

No branches or pull requests

3 participants