Skip to content

Commit 41c55a4

Browse files
authored
Merge pull request #419 from PyAutoLabs/feature/python-312-floor
feat: require Python 3.12
2 parents 9411904 + ca98473 commit 41c55a4

5 files changed

Lines changed: 14 additions & 82 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib python -m pytest t
5151

5252
PRs must pass `pytest --cov` on the CI matrix (Python 3.12 **and** 3.13). There
5353
is no black/ruff/flake8 gate — formatting is advisory. (`requires-python` in
54-
`pyproject.toml` is `>=3.9`.)
54+
`pyproject.toml` is `>=3.12`.)
5555

5656
## Configuration & defaults
5757

autoarray/operators/transformer.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import copy
22
import numpy as np
3-
import sys
43
import warnings
54
from typing import Optional, Tuple
65

@@ -42,32 +41,6 @@ def pynufft_exception():
4241

4342

4443
def nufftax_exception():
45-
# On Python 3.11 `pip install nufftax` is actively bad advice. The releases
46-
# that work with our JAX stack (0.4.x) require Python >= 3.12, so pip resolves
47-
# 0.6.x instead — and 0.6.0/0.6.1 both break the interferometer inversion
48-
# (0.6.0 uses `jax.interpreters.batching.not_mapped`, removed in JAX 0.10;
49-
# 0.6.1 cannot handle the rank-4 input `transform_mapping_matrix` produces
50-
# under vmap). There is currently no nufftax release that both installs on
51-
# 3.11 and works, so send 3.11 users to 3.12+ or to the pynufft backend.
52-
if sys.version_info < (3, 12):
53-
raise ModuleNotFoundError(
54-
"\n--------------------\n"
55-
"You are attempting to perform interferometer analysis with the default "
56-
f"JAX-native `TransformerNUFFT`, on Python {sys.version_info.major}.{sys.version_info.minor}.\n\n"
57-
"The optional library nufftax (https://github.com/GragasLab/nufftax) is not installed, "
58-
"and on this Python version it CANNOT be usefully installed:\n\n"
59-
" - nufftax releases that work with PyAutoArray require Python >= 3.12.\n"
60-
" - The releases that do install here (0.6.x) are incompatible with the "
61-
"JAX version PyAutoArray requires, and fail partway through a fit.\n\n"
62-
"Do NOT `pip install nufftax` on this Python version. Instead either:\n\n"
63-
" 1. Upgrade to Python 3.12 or newer (recommended), then "
64-
"`pip install 'autoarray[optional]'`; or\n"
65-
" 2. Use the legacy pynufft backend, by passing "
66-
"`transformer_class=TransformerNUFFTPyNUFFT` and running "
67-
"`pip install pynufft==2022.2.2`.\n\n"
68-
"----------------------"
69-
)
70-
7144
raise ModuleNotFoundError(
7245
"\n--------------------\n"
7346
"You are attempting to perform interferometer analysis with the default "

pyproject.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dynamic = ["version"]
88
description="PyAuto Data Structures"
99
readme = { file = "README.md", content-type = "text/markdown" }
1010
license = { text = "MIT" }
11-
requires-python = ">=3.9"
11+
requires-python = ">=3.12"
1212
authors = [
1313
{ name = "James Nightingale", email = "James.Nightingale@newcastle.ac.uk" },
1414
{ name = "Richard Hayes", email = "richard@rghsoftware.co.uk" },
@@ -18,9 +18,6 @@ classifiers = [
1818
"Topic :: Scientific/Engineering :: Physics",
1919
"Natural Language :: English",
2020
"Operating System :: OS Independent",
21-
"Programming Language :: Python :: 3.9",
22-
"Programming Language :: Python :: 3.10",
23-
"Programming Language :: Python :: 3.11",
2421
"Programming Language :: Python :: 3.12",
2522
"Programming Language :: Python :: 3.13"
2623
]
@@ -56,7 +53,7 @@ jax = ["autonerves[jax]"]
5653
optional = [
5754
"autoarray[jax]",
5855
"numba",
59-
"nufftax>=0.4.0,<0.5.0; python_version >= '3.12'",
56+
"nufftax>=0.4.0,<0.5.0",
6057
"pynufft",
6158
# tfp provides the modified-Bessel `bessel_kve` used by the JAX Matern-kernel
6259
# regularization path (autoarray/inversion/regularization/matern_kernel.py).
@@ -67,11 +64,11 @@ optional = [
6764
"tfp-nightly==0.26.0.dev20260713"
6865
]
6966
test = ["pytest"]
70-
dev = ["pytest", "black", "numba", "nufftax>=0.4.0,<0.5.0; python_version >= '3.12'", "pynufft==2022.2.2"]
67+
dev = ["pytest", "black", "numba", "nufftax>=0.4.0,<0.5.0", "pynufft==2022.2.2"]
7168

7269
[tool.pytest.ini_options]
7370
testpaths = ["test_autoarray"]
7471
filterwarnings = [
7572
"ignore:cuda_plugin_extension:UserWarning",
7673
"ignore::DeprecationWarning:jax",
77-
]
74+
]

test_autoarray/conftest.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,11 @@ def pytest_collection_modifyitems(config, items):
287287
it is not installed.
288288
289289
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.
290+
``TransformerNUFFT``, backed by the optional ``nufftax`` dependency. When
291+
that backend is absent, any test that builds a default interferometer or
292+
transformer raises ``ModuleNotFoundError`` at construction. Skip exactly
293+
those tests while keeping the explicit ``DFT`` and ``pynufft`` transformer
294+
tests, which have no ``nufftax`` dependency.
297295
"""
298296
try:
299297
import nufftax # noqa: F401
@@ -303,7 +301,7 @@ def pytest_collection_modifyitems(config, items):
303301
pass
304302

305303
skip_nufftax = pytest.mark.skip(
306-
reason="nufftax (default JAX interferometer backend) requires Python >= 3.12"
304+
reason="nufftax (the default JAX interferometer backend) is not installed"
307305
)
308306
for item in items:
309307
name = item.nodeid.rsplit("::", 1)[-1]

test_autoarray/operators/test_transformer.py

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -308,47 +308,11 @@ def f(img_arr):
308308
)
309309

310310

311-
def test__nufftax_exception__pre_3_12_tells_user_to_upgrade_not_to_pip_install():
312-
"""
313-
On Python < 3.12 there is no usable nufftax release: the versions that work
314-
require >= 3.12, and the ones that do install (0.6.x) break mid-fit. The
315-
error must therefore steer the user away from `pip install nufftax`.
316-
"""
317-
import collections
318-
from unittest import mock
311+
def test__nufftax_exception__keeps_the_plain_install_instruction():
319312
from autoarray.operators import transformer
320313

321-
version_info = collections.namedtuple(
322-
"version_info", "major minor micro releaselevel serial"
323-
)
324-
325-
with mock.patch.object(
326-
transformer.sys, "version_info", version_info(3, 11, 0, "final", 0)
327-
):
328-
with pytest.raises(ModuleNotFoundError) as exc:
329-
transformer.nufftax_exception()
330-
331-
message = str(exc.value)
332-
assert "Python 3.11" in message
333-
assert "Do NOT `pip install nufftax`" in message
334-
assert "Python 3.12 or newer" in message
335-
assert "TransformerNUFFTPyNUFFT" in message
336-
337-
338-
def test__nufftax_exception__3_12_and_later_keeps_the_plain_install_instruction():
339-
import collections
340-
from unittest import mock
341-
from autoarray.operators import transformer
342-
343-
version_info = collections.namedtuple(
344-
"version_info", "major minor micro releaselevel serial"
345-
)
346-
347-
with mock.patch.object(
348-
transformer.sys, "version_info", version_info(3, 12, 0, "final", 0)
349-
):
350-
with pytest.raises(ModuleNotFoundError) as exc:
351-
transformer.nufftax_exception()
314+
with pytest.raises(ModuleNotFoundError) as exc:
315+
transformer.nufftax_exception()
352316

353317
message = str(exc.value)
354318
assert "Install it via the command `pip install nufftax`" in message

0 commit comments

Comments
 (0)