Skip to content

Infer NumPy Generator.uniform and exponential result shapes - #5651

Open
AlessandroRuggiero wants to merge 1 commit into
pyrefly-org:mainfrom
AlessandroRuggiero:numpy-generator-uniform-exponential
Open

AlessandroRuggiero wants to merge 1 commit into
pyrefly-org:mainfrom
AlessandroRuggiero:numpy-generator-uniform-exponential

Conversation

@AlessandroRuggiero

Copy link
Copy Markdown
Contributor

Summary

Same pattern as #5619: rng.uniform and rng.exponential now return size's shape, or without size the broadcast shape of array low/high (scale's shape for exponential).

test_issue_4917.py calls rng.uniform with a tuple size, so it now gets exact shapes instead of Any; I updated its expectations. It no longer exercises comparing an unknown-shape array with a float.

  • 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 covering int, tuple, list and symbolic size, array parameters with and without size, mismatched low/high, and the float result without arrays or size. Updated the expectations in test_issue_4917.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)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant