From 71019cc1c7a2b876c30bd8a801478511e312878b Mon Sep 17 00:00:00 2001 From: Goose Date: Mon, 3 Mar 2025 14:57:27 +1000 Subject: [PATCH 1/2] seed flaky GARCH11 test --- tests/distributions/test_timeseries.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/distributions/test_timeseries.py b/tests/distributions/test_timeseries.py index 197296a5a4..1578e03314 100644 --- a/tests/distributions/test_timeseries.py +++ b/tests/distributions/test_timeseries.py @@ -785,7 +785,9 @@ def test_logp(self): @pytest.mark.parametrize("explicit_shape", (True, False)) def test_batched_size(self, explicit_shape, batched_param): steps, batch_size = 100, 5 - param_val = np.square(np.random.randn(batch_size)) + random_seed = 800 + rng = np.random.default_rng(random_seed) + param_val = np.square(rng.random(batch_size)) init_kwargs = { "omega": 1.25, "alpha_1": 0.5, @@ -801,7 +803,7 @@ def test_batched_size(self, explicit_shape, batched_param): with Model() as t0: y = GARCH11("y", **kwargs0) - y_eval = draw(y, draws=2, random_seed=800) + y_eval = draw(y, draws=2, random_seed=random_seed) assert y_eval[0].shape == (batch_size, steps) assert not np.any(np.isclose(y_eval[0], y_eval[1])) From 7b76f677f4998a90d4d262af8c7a1a5853f52d59 Mon Sep 17 00:00:00 2001 From: nataziel <114114079+nataziel@users.noreply.github.com> Date: Mon, 3 Mar 2025 17:39:14 +1000 Subject: [PATCH 2/2] pass generator into draw call Co-authored-by: Ricardo Vieira <28983449+ricardoV94@users.noreply.github.com> --- tests/distributions/test_timeseries.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/distributions/test_timeseries.py b/tests/distributions/test_timeseries.py index 1578e03314..578ef688cd 100644 --- a/tests/distributions/test_timeseries.py +++ b/tests/distributions/test_timeseries.py @@ -803,7 +803,7 @@ def test_batched_size(self, explicit_shape, batched_param): with Model() as t0: y = GARCH11("y", **kwargs0) - y_eval = draw(y, draws=2, random_seed=random_seed) + y_eval = draw(y, draws=2, random_seed=rng) assert y_eval[0].shape == (batch_size, steps) assert not np.any(np.isclose(y_eval[0], y_eval[1]))