Skip to content

Fill gaps in numpy scalar operations and function arguments - #5292

Open
bdelwood wants to merge 2 commits into
facebook:mainfrom
bdelwood:fix/numpy-stub-coverage
Open

bdelwood wants to merge 2 commits into
facebook:mainfrom
bdelwood:fix/numpy-stub-coverage

Conversation

@bdelwood

Copy link
Copy Markdown

Summary

Follows #5291.

The remaining gaps I encountered were in numpy: scalar arithmetic and conversions, array arithmetic with complex and numpy scalars, and missing arguments to arange, round, min, and max. This PR adds support for those operations without attempting to fully model numpy’s dtype promotion rules.

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

Test Plan

Added a few tests.

@meta-codesync

meta-codesync Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

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

@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.

This looks pretty good to me, thanks!

But could you check whether we could just fold complex | number | bool_ into the existing signatures? I think that OtherShape: _Shape = [] + broadcast should hopefully give the same behavior.

We're trying to avoid overloads if possible because overload resolution is slow in a type checker, and overloads make the stubs harder to maintain. If we need them for some reason that's okay, but let's double check that the existing empty-default doesn't work first.

@stroxler stroxler assigned stroxler and unassigned connernilsen Oct 20, 2026
@stroxler
stroxler removed the request for review from connernilsen October 20, 2026 18:34

This branch has not been deployed

No deployments
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.

3 participants