@@ -92,12 +92,13 @@ def test_observe_dims():
9292
9393
9494def test_do ():
95+ rng = np .random .default_rng (seed = 435 )
9596 with pm .Model () as m_old :
9697 x = pm .Normal ("x" , 0 , 1e-3 )
9798 y = pm .Normal ("y" , x , 1e-3 )
9899 z = pm .Normal ("z" , y + x , 1e-3 )
99100
100- assert - 5 < pm .draw (z ) < 5
101+ assert - 5 < pm .draw (z , random_seed = rng ) < 5
101102
102103 m_new = do (m_old , {y : x + 100 })
103104
@@ -106,7 +107,7 @@ def test_do():
106107 assert m_new ["y" ] in m_new .deterministics
107108 assert m_new ["z" ] in m_new .free_RVs
108109
109- assert 95 < pm .draw (m_new ["z" ]) < 105
110+ assert 95 < pm .draw (m_new ["z" ], random_seed = rng ) < 105
110111
111112 # Test two substitutions
112113 with m_old :
@@ -118,10 +119,10 @@ def test_do():
118119 assert m_new ["x" ] not in m_new .deterministics
119120 assert m_new ["z" ] in m_new .free_RVs
120121
121- assert 195 < pm .draw (m_new ["z" ]) < 205
122+ assert 195 < pm .draw (m_new ["z" ], random_seed = rng ) < 205
122123 with m_new :
123124 pm .set_data ({"switch" : 0 })
124- assert - 5 < pm .draw (m_new ["z" ]) < 5
125+ assert - 5 < pm .draw (m_new ["z" ], random_seed = rng ) < 5
125126
126127
127128def test_do_posterior_predictive ():
@@ -149,22 +150,24 @@ def test_do_posterior_predictive():
149150
150151@pytest .mark .parametrize ("mutable" , (False , True ))
151152def test_do_constant (mutable ):
153+ rng = np .random .default_rng (seed = 122 )
152154 with pm .Model () as m :
153155 x = pm .Data ("x" , 0 , mutable = mutable )
154156 y = pm .Normal ("y" , x , 1e-3 )
155157
156158 do_m = do (m , {x : 105 })
157- assert pm .draw (do_m ["y" ]) > 100
159+ assert pm .draw (do_m ["y" ], random_seed = rng ) > 100
158160
159161
160162def test_do_deterministic ():
163+ rng = np .random .default_rng (seed = 435 )
161164 with pm .Model () as m :
162165 x = pm .Normal ("x" , 0 , 1e-3 )
163166 y = pm .Deterministic ("y" , x + 105 )
164167 z = pm .Normal ("z" , y , 1e-3 )
165168
166169 do_m = do (m , {"z" : x - 105 })
167- assert pm .draw (do_m ["z" ]) < 100
170+ assert pm .draw (do_m ["z" ], random_seed = rng ) < 100
168171
169172
170173def test_do_dims ():
0 commit comments