Skip to content

FIX: Align random.draw size dispatch for numpy integers - #919

Open
kocaemre wants to merge 1 commit into
QuantEcon:mainfrom
kocaemre:fix/draw-numpy-integer-size
Open

FIX: Align random.draw size dispatch for numpy integers#919
kocaemre wants to merge 1 commit into
QuantEcon:mainfrom
kocaemre:fix/draw-numpy-integer-size

Conversation

@kocaemre

@kocaemre kocaemre commented Aug 1, 2026

Copy link
Copy Markdown

Closes #918.

Summary

  • Treat numpy integer sizes (for example np.int64(10)) the same as Python int in the pure-Python random.draw path.
  • Keep boolean size values on the scalar branch so Python and jitted dispatch agree.
  • Add focused regression tests covering Python and @njit callers for both cases.

Test plan

  • RED: pytest quantecon/random/tests/test_utilities.py::TestDraw::test_numpy_integer_size_returns_array quantecon/random/tests/test_utilities.py::TestDraw::test_bool_size_is_treated_as_scalar -q failed with the Python path returning a scalar for np.int64(10) and raising TypeError for True.
  • GREEN: same focused command passed: 2 passed in 6.43s.
  • pytest quantecon/random/tests/test_utilities.py -q11 passed in 4.45s.
  • pytest quantecon/random -q11 passed in 4.54s.
  • pytest quantecon -q602 passed, 2 warnings in 504.77s.
  • flake8 --select=F401,F405,E231 quantecon.
  • git diff --check.

Signed-off-by: Emre K <110906681+kocaemre@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

random.draw: size dispatch diverges between the Python and jitted paths for numpy integers

1 participant