Skip to content

Infer NumPy Generator.integers result shapes - #5652

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

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

Conversation

@AlessandroRuggiero

Copy link
Copy Markdown
Contributor

Same pattern as #5619: rng.integers now returns size's shape, or without size the broadcast shape of array low/high. The dtype is kept (int64 by default, or e.g. np.int32 / np.bool_), using a TypeVar default so one set of overloads covers both.

  • 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 scalar results, int, tuple, list and symbolic size, explicit dtypes, array bounds with and without size, and mismatched bounds.

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