On Mon, Jun 29, 2020 at 8:02 AM Neal Becker <[email protected]> wrote:
> I was using this to reset the generator, in order to repeat the same
> sequence again for testing purposes.
>
In general, you should just pass in a new Generator that was created with
the same seed.
def function_to_test(rg):
x = rg.standard_normal()
...
SEED = 12345...
rg = np.random.default_rng(SEED)
function_to_test(rg)
rg = npp.random.default_rng(SEED)
function_to_test(rg)
Resetting the state of the underlying BitGenerator in-place is possible, as
Kevin showed, but if you can refactor your code so that there isn't a
persistent Generator object between these runs, that's probably better.
It's a code smell if you can't just pass in a fresh Generator; in general,
it means that your code is harder to use, not just because we don't expose
an in-place seed() method.
--
Robert Kern
_______________________________________________
NumPy-Discussion mailing list
[email protected]
https://mail.python.org/mailman/listinfo/numpy-discussion