Skip to content

[amss] remove interpolation and replace np.interp #227

Open

Description

@mmcky

The interpolation package is used in the amss lecture as it provided numba jit compatible functions.

The np.interp function is now compatible with numba so we can update this lecture and remove a dependency.

Currently this lecture uses

from interpolation.splines import eval_linear, UCGrid, nodes

hopefully we can find alternatives in numpy as a quick short term fix.

In the medium term we will update this lecture to use jax

Activity

  1. mmcky commented on Aug 6, 2025

    @mmcky
    ContributorAuthor

    @HumphreyYang are you familiar with these lectures?

    We need to replace these interpolation functions with numpy alternatives (for now). Are there any easy replacements?

  2. HumphreyYang commented on Aug 6, 2025

    @HumphreyYang
    Member

    Hi @mmcky, as far as I know there is no simple alternative for UCGrid for multi-dimensional interpolation in numpy.

    There is one in scipy:
    https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.RegularGridInterpolator.html

    Would you like pure numpy implementation?

  3. mmcky commented on Aug 6, 2025

    @mmcky
    ContributorAuthor

    Thanks @HumphreyYang

    Also just FYI I am doing some testing of Copilot.

    I assigned it to fix this issue and here is what it is coming up with so far

    #228

  4. mmcky commented on Aug 6, 2025

    @mmcky
    ContributorAuthor

    Hi @mmcky, as far as I know there is no simple alternative for UCGrid for multi-dimensional interpolation in numpy.

    There is one in scipy: https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.RegularGridInterpolator.html

    Would you like pure numpy implementation?

    I would just need to check if this sits in numba jit or not.

  5. HumphreyYang commented on Aug 6, 2025

    @HumphreyYang
    Member

    Hi @mmcky, I just had a try, no, RegularGridInterpolator is not in numba.

    I think we might need to implement our own interpolator in numpy like what copilot is doing.

    Let's see how it goes.

  6. jstac commented on Aug 6, 2025

    @jstac
    Contributor

    Just noting that this is also in JAX: https://docs.jax.dev/en/latest/_autosummary/jax.scipy.interpolate.RegularGridInterpolator.html

    Maybe someone could bite the bullet and just convert this whole lecture over to JAX...?

  7. HumphreyYang commented on Aug 6, 2025

    @HumphreyYang
    Member

    Maybe someone could bite the bullet and just convert this whole lecture over to JAX...?

    Many thanks @jstac, I can do that!

    I think it would probably easier than writing a numba compatible function that replicates the figure as I did this afternoon : )

  8. jstac commented on Aug 6, 2025

    @jstac
    Contributor

    I think it would probably easier than writing a numba compatible function that replicates the figure as I did this afternoon

    Thanks for doing that @HumphreyYang ! I really appreciate the effort nontheless. What you did was natural and we could pause at that and open a separate issue if you like. I'll leave it up to you.

  9. HumphreyYang commented on Aug 6, 2025

    @HumphreyYang
    Member

    Many thanks, @jstac. I think this issue and PR make a really nice case study on Copilot and AI that we can share with the team.

    It’s my fault for getting a bit too involved in trying to beat the AI by replicating the graph : )

    I’ll leave this issue to @mmcky and start rewriting!

  10. mmcky commented on Aug 6, 2025

    @mmcky
    ContributorAuthor

    Just noting that this is also in JAX: https://docs.jax.dev/en/latest/_autosummary/jax.scipy.interpolate.RegularGridInterpolator.html

    Maybe someone could bite the bullet and just convert this whole lecture over to JAX...?

    thanks @jstac I will start cross checking some of these functions with jax docs

  11. kp992 commented on Aug 6, 2025

    @kp992
    Collaborator

    I agree with the comments above on trying the JAX APIs. Also, the lectures here are in the advanced series so we can prefer JAX over numba even if some of the code looks complex with JAX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions