Skip to content

Commit eadfd75

Browse files
committed
seeding and flipping any
1 parent 436d0f9 commit eadfd75

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

pymc/tests/distributions/test_timeseries.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -835,8 +835,11 @@ class TestEulerMaruyama:
835835
@pytest.mark.parametrize("batched_param", [1, 2])
836836
@pytest.mark.parametrize("explicit_shape", (True, False))
837837
def test_batched_size(self, explicit_shape, batched_param):
838+
RANDOM_SEED = 42
839+
numpy_rng = np.random.default_rng(RANDOM_SEED)
840+
838841
steps, batch_size = 100, 5
839-
param_val = np.square(np.random.randn(batch_size))
842+
param_val = np.square(numpy_rng.standard_normal(batch_size))
840843
if explicit_shape:
841844
kwargs = {"shape": (batch_size, steps)}
842845
else:
@@ -853,9 +856,9 @@ def sde_fn(x, k, d, s):
853856
"y", dt=0.02, sde_fn=sde_fn, sde_pars=sde_pars, init_dist=init_dist, **kwargs
854857
)
855858

856-
y_eval = draw(y, draws=2)
859+
y_eval = draw(y, draws=2, random_seed=RANDOM_SEED)
857860
assert y_eval[0].shape == (batch_size, steps)
858-
assert not np.any(np.isclose(y_eval[0], y_eval[1]))
861+
assert np.any(~np.isclose(y_eval[0], y_eval[1]))
859862

860863
if explicit_shape:
861864
kwargs["shape"] = steps
@@ -873,7 +876,7 @@ def sde_fn(x, k, d, s):
873876
**kwargs,
874877
)
875878

876-
t0_init = t0.initial_point()
879+
t0_init = t0.initial_point(seed=RANDOM_SEED)
877880
t1_init = {f"y_{i}": t0_init["y"][i] for i in range(batch_size)}
878881
np.testing.assert_allclose(
879882
t0.compile_logp()(t0_init),

0 commit comments

Comments
 (0)