Skip to content

Commit c7defd7

Browse files
authored
Merge pull request #23221 from rcomer/devel-random
DOC: recommend numpy random number generator class
2 parents 055452f + 643ffbb commit c7defd7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

doc/devel/testing.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ Random data in tests
8787
Random data is a very convenient way to generate data for examples,
8888
however the randomness is problematic for testing (as the tests
8989
must be deterministic!). To work around this set the seed in each test.
90-
For numpy use::
90+
For numpy's default random number generator use::
9191

9292
import numpy as np
93-
np.random.seed(19680801)
93+
rng = np.random.default_rng(19680801)
94+
95+
and then use ``rng`` when generating the random numbers.
9496

9597
The seed is John Hunter's birthday.
9698

0 commit comments

Comments
 (0)