Skip to content

Commit 469b644

Browse files
Jammy2211claude
authored andcommitted
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 <noreply@anthropic.com>
1 parent 801b1cf commit 469b644

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

test_autoarray/conftest.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,42 @@ def make_acs_ccd():
280280
@pytest.fixture(name="acs_quadrant")
281281
def make_acs_quadrant():
282282
return fixtures.make_acs_quadrant()
283+
284+
285+
def pytest_collection_modifyitems(config, items):
286+
"""Skip interferometer tests that need the default ``nufftax`` backend when
287+
it is not installed.
288+
289+
The default ``Interferometer`` transformer is the JAX-native
290+
``TransformerNUFFT``, backed by ``nufftax`` — which is declared for Python
291+
``>= 3.12`` only (Python 3.9-3.11 are not officially supported). On those
292+
interpreters the backend cannot be installed, so any test that builds a
293+
default interferometer/transformer raises ``ModuleNotFoundError`` at
294+
construction. Skip exactly those, while keeping the explicit ``DFT`` and
295+
``pynufft`` transformer tests, which have no ``nufftax`` dependency. On
296+
3.12/3.13 (where ``nufftax`` is present) nothing is skipped.
297+
"""
298+
try:
299+
import nufftax # noqa: F401
300+
301+
return
302+
except ImportError:
303+
pass
304+
305+
skip_nufftax = pytest.mark.skip(
306+
reason="nufftax (default JAX interferometer backend) requires Python >= 3.12"
307+
)
308+
for item in items:
309+
name = item.nodeid.rsplit("::", 1)[-1]
310+
# Explicit DFT / pynufft backend tests do not use nufftax — keep them.
311+
if "__dft__" in name or "pynufft" in name:
312+
continue
313+
nodeid = item.nodeid.replace("\\", "/")
314+
needs_nufftax = (
315+
"fit/test_fit_interferometer.py" in nodeid
316+
or "dataset/interferometer/test_dataset.py" in nodeid
317+
or "inversion/inversion/interferometer/test_interferometer.py" in nodeid
318+
or ("operators/test_transformer.py" in nodeid and "__nufft__" in name)
319+
)
320+
if needs_nufftax:
321+
item.add_marker(skip_nufftax)

0 commit comments

Comments
 (0)