Skip to content

Infer NumPy Generator.normal result shapes - #5619

Closed
AlessandroRuggiero wants to merge 1 commit into
meta:mainfrom
AlessandroRuggiero:numpy-generator-normal-shapes
Closed

AlessandroRuggiero wants to merge 1 commit into
meta:mainfrom
AlessandroRuggiero:numpy-generator-normal-shapes

Conversation

@AlessandroRuggiero

Copy link
Copy Markdown
Contributor

Summary

Adds shape-aware overloads for Generator.normal. With size, the result has exactly that shape. Without size, it has the broadcast shape of array loc and scale, and mismatched shapes are reported. NumPy's own overloads stay as fallbacks for lists.

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

Test Plan

Added tests to tensor-shapes/pyrefly-numpy-stubs/test/test_random.py.

Ran:

  • python3 tensor-shapes/pyrefly-numpy-stubs/run_pyrefly.py
  • "$TENSOR_SHAPES_VENV/bin/python" tensor-shapes/pyrefly-numpy-stubs/run_runtime_tests.py
  • ./test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extension (formatting and lint)

@meta-cla meta-cla Bot added the cla signed label Nov 11, 2026
@meta-codesync

meta-codesync Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

This pull request has been imported. If you are a Meta employee, you can view this in D131296292. (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.

Review automatically exported from Phabricator review in Meta.

@AlessandroRuggiero

Copy link
Copy Markdown
Contributor Author

@stroxler I don't think I have the permissions to assign this PR to you, as you mentioned in #5595.

@github-actions

Copy link
Copy Markdown

✅ This PR meets all requirements from our pull request checklist.

Optional recommendations:

  • If this PR addresses an open issue, please link the issue in the PR description and claim it.

Note: this comment updates automatically after changes to the PR. Updates may take up to half an hour.

@meta-codesync

meta-codesync Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in cddd16a.

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.

2 participants