diff options
author | Matti Picus <matti.picus@gmail.com> | 2022-10-18 19:26:07 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-18 19:26:07 +0300 |
commit | aed648cceed90b4ae8850ca8d17202578eac654c (patch) | |
tree | 8c582be12223ba200895f941bafd9be8b6940c22 /numpy/random/bit_generator.pyx | |
parent | ac39f38987387307ca099ee69fabf33050e10b33 (diff) | |
parent | ee3c20b9eafa840232ae3e4bfa85ec262fcfa578 (diff) | |
download | numpy-aed648cceed90b4ae8850ca8d17202578eac654c.tar.gz |
Merge pull request #21875 from seberg/weak-scalars-safe-ints
ENH: Implement correct scalar and integer overflow errors for NEP 50
Diffstat (limited to 'numpy/random/bit_generator.pyx')
-rw-r--r-- | numpy/random/bit_generator.pyx | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/numpy/random/bit_generator.pyx b/numpy/random/bit_generator.pyx index c698f6b61..3da4fabce 100644 --- a/numpy/random/bit_generator.pyx +++ b/numpy/random/bit_generator.pyx @@ -68,12 +68,12 @@ def _int_to_uint32_array(n): raise ValueError("expected non-negative integer") if n == 0: arr.append(np.uint32(n)) - if isinstance(n, np.unsignedinteger): - # Cannot do n & MASK32, convert to python int - n = int(n) + + # NumPy ints may not like `n & MASK32` or ``//= 2**32` so use Python int + n = int(n) while n > 0: arr.append(np.uint32(n & MASK32)) - n //= (2**32) + n //= 2**32 return np.array(arr, dtype=np.uint32) def _coerce_to_uint32_array(x): |