Skip to content

fix np.interp type #5231 - #5235

Closed
asukaminato0721 wants to merge 3 commits into
facebook:mainfrom
asukaminato0721:5231
Closed

asukaminato0721 wants to merge 3 commits into
facebook:mainfrom
asukaminato0721:5231

Conversation

@asukaminato0721

Copy link
Copy Markdown
Collaborator

Summary

Fixes #5231

add missing __float__ and np.interp

  • I am a human, and I fully understand the code I am submitting.

Test Plan

add test

@stroxler stroxler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks like a good fix, thanks!

Back to you with a suggested improvement in overload structure; also the PR import didn't work so pushing an updated version will probably help me merge it :)

Comment on lines +1627 to +1629
@overload
def interp[Shape: _Shape](
x: ndarray[Shape] | RegularNestedList[Shape, _ArrayScalar],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this overload to

@overload
def interp[N: IntVar, Rest: _Shape = []](
    x: ndarray[[N, *Rest]]
    | RegularNestedList[[N, *Rest], _ArrayScalar],
    ...
) -> ndarray[[N, *Rest]]: ...

so that we rule out matching an empty shape here?

I think if we make that change it might also be able to combine the first and last overloads into just one, because we will have solved the the overlapping-overloads problem.

The current diff uses ordering to try to fix the overlap, but python overload resolution is only partially and ambiguously order-dependent, so it's much cleaner if we can just make the overloads non-overlapping.

@stroxler

Copy link
Copy Markdown
Contributor

No auto-import unfortunately :/

I'll try to get this reviewed and merged, thanks!

@meta-codesync

meta-codesync Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@stroxler has imported this pull request. If you are a Meta employee, you can view this in D125328983. (Because this pull request was imported automatically, there will not be any future comments.)

@rchen152 rchen152 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot closed this in 0a9dca8 Oct 14, 2026
@meta-codesync meta-codesync Bot added the Merged label Oct 14, 2026
@meta-codesync

meta-codesync Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@stroxler merged this pull request in 0a9dca8.

@asukaminato0721
asukaminato0721 deleted the 5231 branch October 15, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

np.interp type

3 participants