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

ValueError: high is out of bounds for int32 #20

Open
tgbrooks opened this issue Oct 28, 2022 · 0 comments
Open

ValueError: high is out of bounds for int32 #20

tgbrooks opened this issue Oct 28, 2022 · 0 comments

Comments

@tgbrooks
Copy link

There appears to be a compatibility issue with numpy on Windows. On line 352 of main.py, there is:

 self.seeds = list(np.random.randint(0, self.uint32max, size=int(N)))

Where self.uint32max == 4294967295 == 2**32 - 1. However, this is giving the error ValueError: high is out of bounds for int32 which indicates that numpy defaults to the wrong type. One solution is to reduce this to 2**31 - 1 (or 2**31 works since the upper bound is not inclusive for randint). Another solution is to specify the type:

 self.seeds = list(np.random.randint(0, self.uint32max, size=int(N), dtype=np.uint32)) #or np.int64

Lastly, as a somewhat side remark, numpy now recommends a different random number generator interface, such as through np.random.default_rng(). One difficulty is that currently noisyopt wants to set the seeds of the global numpy RNG, but any functions using the new RNG system will be unaffected. Instead, noisyopt would have to pass a Generator object to the optimization function for it to use.

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

No branches or pull requests

1 participant