Reputation: 5233
I am calling
np.random.seed(seed)
random.seed(seed)
in the __main__
module foo.py
. That module calls out to another module bar.py
that also uses results from np.random
and random
. Does the latter also need to set the seed?
Upvotes: 0
Views: 63
Reputation: 362836
No. Using np.random.seed(...)
sets a global random state.
Usually this is not desirable. You may prefer to use a np.random.RandomState()
instance in your code, so that you don't also seed the PRNGs for all other library code within your runtime.
Upvotes: 2