From 32b0e73a0ce7ace7b874370284a29640bb8dac1d Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sat, 11 Jul 2026 11:45:23 +0100 Subject: [PATCH] test: skip jax-backed tests when jax is absent (Python matrix) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These tests exercise jax-only code paths (vmapped profiles / blackjax NUTS / nufft sparse operator / use_jax=True), so they need jax installed to run — it ships via the [optional] extras and is present in the per-repo CI (3.12/3.13). The PyAutoBuild Python Version Matrix installs the NumPy-only stack (and jax can't install on 3.9 anyway), so guard the 2 affected test(s) with a skipif on jax availability rather than letting them ModuleNotFoundError. Numpy-only tests in the same files are unaffected. Co-Authored-By: Claude Opus 4.8 --- .../profiles/mass/dark/test_kaplinghat.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test_autogalaxy/profiles/mass/dark/test_kaplinghat.py b/test_autogalaxy/profiles/mass/dark/test_kaplinghat.py index 6616d239..6d14fbc8 100644 --- a/test_autogalaxy/profiles/mass/dark/test_kaplinghat.py +++ b/test_autogalaxy/profiles/mass/dark/test_kaplinghat.py @@ -1,8 +1,18 @@ +import importlib.util + import numpy as np import pytest import autogalaxy as ag +# The `vmapped_deflections_from` path is jax-backed; these tests need jax +# installed to run (it 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)", +) + def test__zero_interaction_limit_matches_nfw(): kaplinghat = ag.mp.KaplinghatCoredNFWSph( @@ -59,6 +69,7 @@ def test__lensing_quantities_are_finite_and_positive(): assert deflections[0] == pytest.approx(np.array([0.0, 0.0]), abs=1.0e-8) +@requires_jax def test__vmapped_deflections_match_instance_path_for_zero_interaction(): profile = ag.mp.KaplinghatCoredNFWSph( centre=(0.1, -0.2), @@ -97,6 +108,7 @@ def test__vmapped_deflections_match_instance_path_for_zero_interaction(): ) +@requires_jax def test__vmapped_deflections_match_instance_path_for_sidm_core(): profile = ag.mp.KaplinghatCoredNFWSph( centre=(0.1, -0.2),