From e4b7ef4a1c07bec2faf1247577ce3e8d20f63d4f Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sat, 11 Jul 2026 12:56:13 +0100 Subject: [PATCH] docs: skip blackjax-backed example when the backend is absent The Python Version Matrix installs the NumPy-only stack, so scripts/searches/mcmc.py failed with ModuleNotFoundError on the optional blackjax backend. Add a find_spec guard that skips the blackjax section gracefully (print + exit 0) when it is not installed; the example runs in full under the release stack. Co-Authored-By: Claude Opus 4.8 --- scripts/searches/mcmc.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/searches/mcmc.py b/scripts/searches/mcmc.py index 611a56ed..e3b6db0b 100644 --- a/scripts/searches/mcmc.py +++ b/scripts/searches/mcmc.py @@ -264,7 +264,22 @@ If you use `BlackJAXNUTS` as part of a published work, please cite the BlackJAX package following the instructions on its GitHub page. + +`BlackJAXNUTS` needs the `blackjax` package, which ships with the `[optional]` +extras (`pip install autofit[optional]`). When it is not installed (e.g. the +NumPy-only CI matrix), skip the remaining NUTS section — the `Emcee` and `Zeus` +examples above have already run. """ +import importlib.util +import sys + +if importlib.util.find_spec("blackjax") is None: + print( + "Skipping BlackJAXNUTS example: the `blackjax` package is not installed " + "(install with `pip install autofit[optional]`)." + ) + sys.exit(0) + from autofit.jax.pytrees import enable_pytrees, register_model enable_pytrees()