From 469b644f371eeba68fb3b456f3299465fb0d4355 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Sat, 11 Jul 2026 11:01:41 +0100 Subject: [PATCH] test: skip default-nufftax interferometer tests when nufftax absent The default Interferometer transformer is the JAX-native TransformerNUFFT, backed by nufftax (declared for Python >= 3.12 only). On 3.9-3.11 (not officially supported) the backend can't install, so default interferometer / transformer tests raise ModuleNotFoundError at construction. Add a pytest_collection_modifyitems hook that skips exactly those when nufftax is unavailable, keeping the explicit DFT and pynufft transformer tests. On 3.12/3.13 nothing is skipped. Fixes the PyAutoBuild Python Version Matrix red on 3.9-3.11 (paired with PyAutoArray[optional] in that workflow). Co-Authored-By: Claude Opus 4.8 --- test_autoarray/conftest.py | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test_autoarray/conftest.py b/test_autoarray/conftest.py index e9495ebf..f4577bca 100644 --- a/test_autoarray/conftest.py +++ b/test_autoarray/conftest.py @@ -280,3 +280,42 @@ def make_acs_ccd(): @pytest.fixture(name="acs_quadrant") def make_acs_quadrant(): return fixtures.make_acs_quadrant() + + +def pytest_collection_modifyitems(config, items): + """Skip interferometer tests that need the default ``nufftax`` backend when + it is not installed. + + The default ``Interferometer`` transformer is the JAX-native + ``TransformerNUFFT``, backed by ``nufftax`` — which is declared for Python + ``>= 3.12`` only (Python 3.9-3.11 are not officially supported). On those + interpreters the backend cannot be installed, so any test that builds a + default interferometer/transformer raises ``ModuleNotFoundError`` at + construction. Skip exactly those, while keeping the explicit ``DFT`` and + ``pynufft`` transformer tests, which have no ``nufftax`` dependency. On + 3.12/3.13 (where ``nufftax`` is present) nothing is skipped. + """ + try: + import nufftax # noqa: F401 + + return + except ImportError: + pass + + skip_nufftax = pytest.mark.skip( + reason="nufftax (default JAX interferometer backend) requires Python >= 3.12" + ) + for item in items: + name = item.nodeid.rsplit("::", 1)[-1] + # Explicit DFT / pynufft backend tests do not use nufftax — keep them. + if "__dft__" in name or "pynufft" in name: + continue + nodeid = item.nodeid.replace("\\", "/") + needs_nufftax = ( + "fit/test_fit_interferometer.py" in nodeid + or "dataset/interferometer/test_dataset.py" in nodeid + or "inversion/inversion/interferometer/test_interferometer.py" in nodeid + or ("operators/test_transformer.py" in nodeid and "__nufft__" in name) + ) + if needs_nufftax: + item.add_marker(skip_nufftax)