From 290c9c2975baedc6afbc03e4d47c55c19f20e7f1 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sat, 11 Jul 2026 12:07:26 +0100 Subject: [PATCH] test: guard blackjax NUTS tests on blackjax, not jax (Python matrix) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to #1358: the two _times_from_positions tests were guarded on jax, but they need *blackjax* (which pulls jax). jax installs on 3.11+ via the autoarray/autolens [optional] chain, so requires_jax did not skip them there — and blackjax lives in autofit's own [optional], which the matrix does not install, so they failed with 'No module named blackjax' on 3.11/3.12/3.13. Guard on blackjax instead; skips across the whole matrix, runs in per-repo CI (which installs autofit[optional]). Co-Authored-By: Claude Opus 4.8 --- .../non_linear/search/mcmc/test_blackjax_nuts.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test_autofit/non_linear/search/mcmc/test_blackjax_nuts.py b/test_autofit/non_linear/search/mcmc/test_blackjax_nuts.py index 1621a73a1..fbc55bd28 100644 --- a/test_autofit/non_linear/search/mcmc/test_blackjax_nuts.py +++ b/test_autofit/non_linear/search/mcmc/test_blackjax_nuts.py @@ -8,12 +8,12 @@ _times_from_positions, ) -# `_times_from_positions` is jax-backed; it needs jax installed to run (jax -# ships via the `[optional]` extras). The NumPy-only Python-version matrix has -# no jax, so skip there rather than fail. -requires_jax = pytest.mark.skipif( - importlib.util.find_spec("jax") is None, - reason="requires jax (installed via the [optional] extras; absent on the NumPy-only matrix env)", +# `_times_from_positions` runs blackjax (which pulls jax); both ship via the +# `[optional]` extras. The Python-version matrix installs autofit without those +# extras, so skip there rather than fail with `No module named 'blackjax'`. +requires_blackjax = pytest.mark.skipif( + importlib.util.find_spec("blackjax") is None, + reason="requires blackjax (installed via the [optional] extras; absent on the matrix env)", ) pytestmark = pytest.mark.filterwarnings("ignore::FutureWarning") @@ -101,7 +101,7 @@ def test__identifier_fields_distinguish_run_shape(): assert (c.num_warmup, c.num_samples, c.num_chains) == (100, 999, 1) -@requires_jax +@requires_blackjax def test__times_from_positions_clamps_low_ess(): # Construct a degenerate "chain" — every sample is identical → ESS # collapses; the clamp must keep ``times`` finite and equal to N. @@ -118,7 +118,7 @@ def test__times_from_positions_clamps_low_ess(): assert np.all(times <= n_samples + 1e-9) -@requires_jax +@requires_blackjax def test__times_from_positions_independent_chain(): # Independent draws → ESS ≈ N, so τ ≈ 1. rng = np.random.default_rng(1)