<div dir="ltr"><div dir="ltr">On Mon, Jun 29, 2020 at 8:02 AM Neal Becker <<a href="mailto:ndbecker2@gmail.com">ndbecker2@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I was using this to reset the generator, in order to repeat the same sequence again for testing purposes.</div></blockquote></div><div><br></div>In general, you should just pass in a new Generator that was created with the same seed.<div><br></div><div>def function_to_test(rg):</div><div>    x = rg.standard_normal()</div><div>    ...</div><div><br></div><div>SEED = 12345...</div><div><br></div><div>rg = np.random.default_rng(SEED)<br clear="all"><div>function_to_test(rg)</div><div>rg = npp.random.default_rng(SEED)</div><div>function_to_test(rg)</div><div><br></div><div>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.</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Robert Kern</div></div></div>