rzshrote / pybrops

Python Breeding Optimizer and Simulator: A Python library for simulating and optimizing breeding pipelines.
https://rzshrote.github.io/pybrops/
MIT License
2 stars 1 forks source link

pybropt.core.random seed set does not work #47

Closed rzshrote closed 2 years ago

rzshrote commented 2 years ago

Setting the seed does not result in deterministic results. I am not sure where this is coming from. This error appears to be directly related to the seed function.

Sample output:

>>> import pybropt.core.random
>>> pybropt.core.random.seed(941)
>>> pybropt.core.random.uniform(0,1,5)
array([0.41593583, 0.74514777, 0.82355187, 0.96258013, 0.05200834])
>>> pybropt.core.random.seed(941)
>>> pybropt.core.random.uniform(0,1,5)
array([0.54305351, 0.56444802, 0.35755851, 0.2464574 , 0.85001113])
rzshrote commented 2 years ago

Issue was with how function aliases weren't accessing the global random number generator for numpy. Fixed by eliminating wrapper class to handle seeding and spawning of new generators. The new implementation is a simpler and more robust wrapper module (no wrapper classes within the module though).