Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed out-of-bounds when generating random on Windows #233

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

Skielex
Copy link
Collaborator

@Skielex Skielex commented Aug 1, 2024

The function

@datagen("i64")
def uniform():
    return np.random.randint(-(2**63), 2**63, size=max_n)[:n]

raises an error on Windows due to using i32 type.

Traceback (most recent call last):
  File "...\generate_randoms.py", line 352, in <module>
    data = f()
  File "...\generate_randoms.py", line 129, in uniform
    return np.random.randint(-(2**63), 2**63, size=max_n)[:n]
  File "numpy\\random\\mtrand.pyx", line 780, in numpy.random.mtrand.RandomState.randint
  File "numpy\\random\\_bounded_integers.pyx", line 2877, in numpy.random._bounded_integers._rand_int32
ValueError: low is out of bounds for int32

Specifying dtype=np.int64 fixes this.

@mwlon mwlon merged commit 8ec9cc2 into main Aug 2, 2024
2 checks passed
@mwlon mwlon deleted the gen-rand-i64-win branch August 2, 2024 01:00
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.

2 participants