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

DOC: Suggested improvement to interp2d transition guide #20620

Open
telegraphic opened this issue May 1, 2024 · 1 comment
Open

DOC: Suggested improvement to interp2d transition guide #20620

telegraphic opened this issue May 1, 2024 · 1 comment
Labels
Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org scipy.interpolate

Comments

@telegraphic
Copy link

telegraphic commented May 1, 2024

Issue with current documentation:

The current documentation does not mention that interp2d has a default kind='linear' kwarg:

class scipy.interpolate.interp2d(x, y, z, kind='linear', copy=True, bounds_error=False, fill_value=None)

while the suggested replacement, RectBivariateSpline, has a default ky=3 kwarg:

class scipy.interpolate.RectBivariateSpline(x, y, z, bbox=[None, None, None, None], kx=3, ky=3, s=0)

That is, the default spline degree differs.

Idea or request for content:

A simple fix is to note that the default

f = interp2d(x, y, z)

uses linear spline, but

r = RectBivariateSpline(x, y, z.T)

uses a cubic spline as default. Explicitly mention the required kwargs that need to be added to RectBivariateSpline to make it match the default interp2d function.

Maybe add a little table that shows how to get identical results, e.g.

interp2d RectBivariateSpline
no kwargs kx, ky = 1
kind='linear' kx, ky = 1
kind='cubic' kx, ky = 3

Hope this doc suggestion can help others. I suspect the impending deprecation of interp2d is going to cause a fair few codes to catch on fire, so really pleased y'all have written the transition guide 🙏.

Additional context (e.g. screenshots, GIFs)

No response

@telegraphic telegraphic added the Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org label May 1, 2024
@ev-br
Copy link
Member

ev-br commented May 1, 2024

Would you be interested in sending a pull request with this clarification?
EDIT: and/or any other tweaks you think would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org scipy.interpolate
Projects
None yet
Development

No branches or pull requests

3 participants