Skip to content

Commit 1ed0922

Browse files
authored
Merge branch 'main' into saransh/rm-Python-3.9
2 parents acc68c4 + 8d03079 commit 1ed0922

File tree

5 files changed

+87
-20
lines changed

5 files changed

+87
-20
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242
- "3.11"
4343
- "3.12"
4444
- "3.13"
45+
- "3.14"
46+
- "3.14t"
4547
name: Python ${{ matrix.python-version }} - Lite
4648
steps:
4749
- uses: actions/checkout@v6
@@ -67,6 +69,8 @@ jobs:
6769
- "3.11"
6870
- "3.12"
6971
- "3.13"
72+
- "3.14"
73+
- "3.14t"
7074
name: Python ${{ matrix.python-version }} - Full
7175
steps:
7276
- uses: actions/checkout@v6

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ repos:
1919
- id: trailing-whitespace
2020

2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: "v0.14.10"
22+
rev: "v0.14.11"
2323
hooks:
2424
- id: ruff-check
2525
args: ["--fix", "--show-fixes"]

noxfile.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
from __future__ import annotations
88

9+
import os
10+
import sys
11+
import sysconfig
912
from pathlib import Path
1013

1114
import nox
@@ -16,6 +19,7 @@
1619
DIR = Path(__file__).parent.resolve()
1720
PYPROJECT = nox.project.load_toml(DIR / "pyproject.toml")
1821
ALL_PYTHON = nox.project.python_versions(PYPROJECT)
22+
ALL_PYTHON += ["3.14t"] # add free-threaded Python variant
1923

2024

2125
@nox.session(reuse_venv=True)
@@ -44,7 +48,13 @@ def lite(session: nox.Session) -> None:
4448
@nox.session(reuse_venv=True, python=ALL_PYTHON)
4549
def tests(session: nox.Session) -> None:
4650
"""Run the unit and regular tests."""
47-
test_deps = nox.project.dependency_groups(PYPROJECT, "test-all")
51+
if sys.version_info[:2] >= (3, 14) and bool(
52+
sysconfig.get_config_var("Py_GIL_DISABLED")
53+
):
54+
os.environ["PYTHON_GIL"] = "0"
55+
test_deps = nox.project.dependency_groups(PYPROJECT, "test-all-no-gil")
56+
else:
57+
test_deps = nox.project.dependency_groups(PYPROJECT, "test-all-gil")
4858
session.install("-e.", *test_deps)
4959
session.run(
5060
"pytest",
@@ -64,15 +74,17 @@ def coverage(session: nox.Session) -> None:
6474
@nox.session(reuse_venv=True, python=ALL_PYTHON)
6575
def doctests(session: nox.Session) -> None:
6676
"""Run the doctests."""
67-
test_deps = nox.project.dependency_groups(PYPROJECT, "test-all")
77+
test_deps = nox.project.dependency_groups(PYPROJECT, "test-all-gil")
6878
session.install("-e.", *test_deps)
6979
session.run("pytest", "--doctest-plus", "src/vector/", *session.posargs)
7080

7181

7282
@nox.session(reuse_venv=True, default=False)
7383
def notebooks(session: nox.Session) -> None:
7484
"""Run the notebook tests"""
75-
test_deps = nox.project.dependency_groups(PYPROJECT, "test", "test-optional")
85+
test_deps = nox.project.dependency_groups(
86+
PYPROJECT, "test", "test-optional", "test-numba"
87+
)
7688
session.install("-e.", *test_deps)
7789
session.install("jupyter")
7890
session.run("pytest", "tests/test_notebooks.py", *session.posargs)

pyproject.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ classifiers = [
3232
"Programming Language :: Python :: 3.12",
3333
"Programming Language :: Python :: 3.13",
3434
"Programming Language :: Python :: 3.14",
35+
"Programming Language :: Python :: Free Threading :: 3 - Stable",
3536
"Topic :: Scientific/Engineering",
3637
"Topic :: Scientific/Engineering :: Information Analysis",
3738
"Topic :: Scientific/Engineering :: Mathematics",
@@ -71,9 +72,11 @@ test = [
7172
]
7273
test-optional = [
7374
"awkward>=2",
74-
"numba>=0.62; python_version<'3.15'",
7575
"sympy",
7676
]
77+
test-numba = [
78+
"numba>=0.57; python_version<'3.15'",
79+
]
7780
test-extras = [
7881
"jax",
7982
"dask_awkward",
@@ -93,14 +96,19 @@ docs = [
9396
"hepunits",
9497
"matplotlib",
9598
]
96-
test-all = [
99+
test-all-no-gil = [
97100
{ include-group = "test"},
98101
{ include-group = "test-optional"},
99102
{ include-group = "test-extras"},
100103
]
104+
test-all-gil = [
105+
{ include-group = "test-all-no-gil"},
106+
{ include-group = "test-numba"},
107+
]
101108
dev = [
102109
{ include-group = "test"},
103110
{ include-group = "test-optional"},
111+
{ include-group = "test-numba"},
104112
]
105113

106114
[tool.hatch]

tests/backends/test_numba_object.py

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,38 +48,81 @@ def two(obj):
4848
return obj, obj
4949

5050
obj = vector.obj(x=1, y=2)
51-
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (2, 2)
51+
if sys.version_info[:2] <= (3, 13):
52+
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (2, 2)
53+
else:
54+
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (1, 2)
5255

5356
class_refs = None
5457
for _ in range(10):
5558
zero(obj)
56-
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (2, 2)
59+
if sys.version_info[:2] <= (3, 13):
60+
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (2, 2)
61+
else:
62+
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (1, 2)
63+
5764
if class_refs is None:
5865
class_refs = sys.getrefcount(vector.backends.object.VectorObject2D)
59-
assert class_refs + 1 == sys.getrefcount(vector.backends.object.VectorObject2D)
66+
if sys.version_info[:2] <= (3, 13):
67+
assert class_refs + 1 == sys.getrefcount(
68+
vector.backends.object.VectorObject2D
69+
)
70+
else:
71+
assert class_refs == sys.getrefcount(vector.backends.object.VectorObject2D)
6072

6173
class_refs = None
6274
for _ in range(10):
6375
a = one(obj)
64-
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (2, 2)
65-
assert (sys.getrefcount(a), sys.getrefcount(a.azimuthal)) == (2, 2)
76+
if sys.version_info[:2] <= (3, 13):
77+
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (2, 2)
78+
else:
79+
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (1, 2)
80+
81+
if sys.version_info[:2] <= (3, 13):
82+
assert (sys.getrefcount(a), sys.getrefcount(a.azimuthal)) == (2, 2)
83+
else:
84+
assert (sys.getrefcount(a), sys.getrefcount(a.azimuthal)) == (1, 2)
85+
6686
if class_refs is None:
6787
class_refs = sys.getrefcount(vector.backends.object.VectorObject2D)
68-
assert class_refs + 1 == sys.getrefcount(vector.backends.object.VectorObject2D)
88+
if sys.version_info[:2] <= (3, 13):
89+
assert class_refs + 1 == sys.getrefcount(
90+
vector.backends.object.VectorObject2D
91+
)
92+
else:
93+
assert class_refs == sys.getrefcount(vector.backends.object.VectorObject2D)
6994

7095
class_refs = None
7196
for _ in range(10):
7297
a, b = two(obj)
73-
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (2, 2)
74-
assert (
75-
sys.getrefcount(a),
76-
sys.getrefcount(a.azimuthal),
77-
sys.getrefcount(b),
78-
sys.getrefcount(b.azimuthal),
79-
) == (2, 2, 2, 2)
98+
if sys.version_info[:2] <= (3, 13):
99+
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (2, 2)
100+
else:
101+
assert (sys.getrefcount(obj), sys.getrefcount(obj.azimuthal)) == (1, 2)
102+
103+
if sys.version_info[:2] <= (3, 13):
104+
assert (
105+
sys.getrefcount(a),
106+
sys.getrefcount(a.azimuthal),
107+
sys.getrefcount(b),
108+
sys.getrefcount(b.azimuthal),
109+
) == (2, 2, 2, 2)
110+
else:
111+
assert (
112+
sys.getrefcount(a),
113+
sys.getrefcount(a.azimuthal),
114+
sys.getrefcount(b),
115+
sys.getrefcount(b.azimuthal),
116+
) == (1, 2, 1, 2)
117+
80118
if class_refs is None:
81119
class_refs = sys.getrefcount(vector.backends.object.VectorObject2D)
82-
assert class_refs + 1 == sys.getrefcount(vector.backends.object.VectorObject2D)
120+
if sys.version_info[:2] <= (3, 13):
121+
assert class_refs + 1 == sys.getrefcount(
122+
vector.backends.object.VectorObject2D
123+
)
124+
else:
125+
assert class_refs == sys.getrefcount(vector.backends.object.VectorObject2D)
83126

84127
# These tests just check that the rest of the implementations are sane.
85128

0 commit comments

Comments
 (0)