From 643ffbbded13cb94c8e6e6ce362fb6ba6cf3366e Mon Sep 17 00:00:00 2001 From: Ruth Comer Date: Wed, 8 Jun 2022 07:47:23 +0100 Subject: [PATCH] DOC: recommend numpy random number generator class --- doc/devel/testing.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/devel/testing.rst b/doc/devel/testing.rst index 13a6261b59e1..35a5195716d7 100644 --- a/doc/devel/testing.rst +++ b/doc/devel/testing.rst @@ -87,10 +87,12 @@ Random data in tests Random data is a very convenient way to generate data for examples, however the randomness is problematic for testing (as the tests must be deterministic!). To work around this set the seed in each test. -For numpy use:: +For numpy's default random number generator use:: import numpy as np - np.random.seed(19680801) + rng = np.random.default_rng(19680801) + +and then use ``rng`` when generating the random numbers. The seed is John Hunter's birthday.