Skip to content

Commit 63e6a62

Browse files
Make recirq/kpz/experiment_test.py deterministic (#391)
Add constant seed so that the sampler and RNG generator are deterministic. This will fix flakiness in test_size_independence_muinf within recirq/kpz/experiment_test.py Note that the test can still produce different results if multi-threaded pytest is used depending on the order of execution of different tests, but this will vastly reduce the number of cases tested.
1 parent 00b51f6 commit 63e6a62

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

recirq/kpz/experiment_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020

2121
_CYCLES = 1
2222
_MU = np.inf
23-
_SAMPLER = cirq.Simulator()
23+
_SAMPLER = cirq.Simulator(seed=0)
2424
_TRIALS = 1000
2525
_REPS = 1000
26-
rng = np.random.default_rng()
26+
rng = np.random.default_rng(0)
2727

2828

2929
def test_muinf_against_analytics():

0 commit comments

Comments
 (0)