Skip to content

Commit 53fb5fc

Browse files
Drop support for awkward v1 (#434)
* Drop support for awkward v1 * style: pre-commit fixes * Fix CI * format * rm awkward v1 pickle file * use nox in ci * Informative name * update notebook tests * dask_awkward should not be installed in lite tests * Use correct python versions * Correct matrix name * Resolve pip backtracking issue * update changelog * fix awkward tests * Update noxfile * Update numpy 2 tests * get rid of numpy 2 nox session * fix notebook tests * update docs * fix record reducers tests --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 0401fcc commit 53fb5fc

File tree

13 files changed

+86
-184
lines changed

13 files changed

+86
-184
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.ref }}
1515
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1616

17+
env:
18+
# The "FORCE_COLOR" variable, when set to 1,
19+
# tells Nox to colorize itself.
20+
FORCE_COLOR: "1"
21+
1722
jobs:
1823
pre-commit:
1924
runs-on: ubuntu-latest
@@ -28,44 +33,7 @@ jobs:
2833
echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json"
2934
pipx run nox -s pylint
3035
31-
check-light:
32-
runs-on: ubuntu-latest
33-
strategy:
34-
fail-fast: false
35-
matrix:
36-
python-version:
37-
- "3.8"
38-
- "3.9"
39-
- "3.10"
40-
- "3.11"
41-
- "3.12"
42-
name: Python ${{ matrix.python-version }} - Light
43-
steps:
44-
- uses: actions/checkout@v4
45-
46-
- uses: actions/setup-python@v5
47-
with:
48-
python-version: ${{ matrix.python-version }}
49-
50-
- name: Requirements check
51-
run: python -m pip list
52-
53-
- name: Install package
54-
run: python -m pip install -e .[test]
55-
56-
- name: Test light package
57-
run: python -m pytest -ra --ignore tests/test_notebooks.py
58-
59-
- name: Install numpy v2
60-
if: matrix.python-version != 3.8
61-
run: python -m pip install "numpy>=2.0.0b1"
62-
63-
- name: Test light package with numpy v2.x
64-
if: matrix.python-version != 3.8
65-
run: python -m pytest -ra --ignore tests/test_notebooks.py
66-
67-
check-awkward-v1:
68-
needs: [check-light]
36+
check-lite:
6937
runs-on: ubuntu-latest
7038
strategy:
7139
fail-fast: false
@@ -76,7 +44,7 @@ jobs:
7644
- "3.10"
7745
- "3.11"
7846
- "3.12"
79-
name: Python ${{ matrix.python-version }} - Awkward v1
47+
name: Python ${{ matrix.python-version }} - Lite
8048
steps:
8149
- uses: actions/checkout@v4
8250

@@ -87,21 +55,11 @@ jobs:
8755
- name: Requirements check
8856
run: python -m pip list
8957

90-
- name: Install package
91-
run: python -m pip install -e .[dev]
92-
93-
- name: Install awkward v1 and numpy v1
94-
run: python -m pip install -U "awkward<2" "numpy<2"
95-
96-
- name: Run doctests on Python 3.11 with awkward v1.x and numpy v1.x
97-
if: matrix.python-version == '3.11'
98-
run: python -m pytest -ra --doctest-plus src/vector/
58+
- name: Test lite package
59+
run: pipx run nox -s lite-${{ matrix.python-version.key || matrix.python-version }} --verbose
9960

100-
- name: Test package with awkward v1.x
101-
run: python -m pytest -ra --cov=vector --ignore tests/test_notebooks.py .
102-
103-
check-awkward-v2:
104-
needs: [check-light]
61+
check-full:
62+
needs: [check-lite]
10563
runs-on: ubuntu-latest
10664
strategy:
10765
fail-fast: false
@@ -112,7 +70,7 @@ jobs:
11270
- "3.10"
11371
- "3.11"
11472
- "3.12"
115-
name: Python ${{ matrix.python-version }} - Awkward v2
73+
name: Python ${{ matrix.python-version }} - Full
11674
steps:
11775
- uses: actions/checkout@v4
11876

@@ -123,18 +81,12 @@ jobs:
12381
- name: Requirements check
12482
run: python -m pip list
12583

126-
- name: Install package
127-
run: python -m pip install -e .[dev]
128-
129-
- name: Install awkward v2
130-
run: python -m pip install -U awkward "numpy<2.1"
131-
132-
- name: Run doctests on Python 3.11 with awkward v2.x
84+
- name: Run doctests on Python 3.11
13385
if: matrix.python-version == 3.11
134-
run: python -m pytest -ra --doctest-plus src/vector/
86+
run: pipx run nox -s doctests-${{ matrix.python-version.key || matrix.python-version }} --verbose
13587

136-
- name: Test package with awkward v2.x
137-
run: python -m pytest -ra --cov=vector --ignore tests/test_notebooks.py .
88+
- name: Test package and generate coverage report
89+
run: pipx run nox -s coverage-${{ matrix.python-version.key || matrix.python-version }} --verbose
13890

13991
- name: Upload coverage report
14092
uses: codecov/codecov-action@v4.5.0
@@ -161,8 +113,7 @@ jobs:
161113
run: python -m pytest -ra -m dis --ignore tests/test_notebooks.py
162114

163115
pass:
164-
needs:
165-
[pre-commit, check-light, check-awkward-v1, check-awkward-v2, discheck]
116+
needs: [pre-commit, check-lite, check-full, discheck]
166117
runs-on: ubuntu-latest
167118
steps:
168119
- run: echo "All jobs passed"

.github/workflows/notebooks.yml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,25 @@ concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}
1212
cancel-in-progress: true
1313

14+
env:
15+
# The "FORCE_COLOR" variable, when set to 1,
16+
# tells Nox to colorize itself.
17+
FORCE_COLOR: "1"
18+
1419
jobs:
1520
test:
1621
runs-on: ubuntu-latest
17-
strategy:
18-
matrix:
19-
python-version: ["3.10"]
2022

2123
steps:
2224
- uses: actions/checkout@v4
2325

2426
- name: Set up Python
2527
uses: actions/setup-python@v5
2628
with:
27-
python-version: ${{ matrix.python-version }}
28-
29-
- name: Install dependencies
30-
run: |
31-
python -m pip install --upgrade pip setuptools wheel
32-
python -m pip install --upgrade .[dev]
33-
python -m pip install numba uproot
34-
python -m pip install jupyter papermill
29+
python-version: "3.10"
3530

3631
- name: List installed Python packages
3732
run: python -m pip list
3833

3934
- name: Test example notebooks
40-
run: |
41-
pytest tests/test_notebooks.py
35+
run: pipx run nox -s notebooks

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This overview is based on the [documentation here](https://vector.readthedocs.io
4444
```python
4545
import vector
4646
import numpy as np
47-
import awkward as ak # at least version 1.2.0
47+
import awkward as ak # at least v2.0.0 (vector v1.4.* supports awkward v1 and v2 both)
4848
import numba as nb
4949
```
5050

docs/changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## Version 1.5
4+
5+
### Version 1.5.0
6+
7+
#### Breaking
8+
9+
- drop support for awkward v1 [#434][]
10+
11+
[#434]: https://github.com/scikit-hep/vector/pull/434
12+
313
## Version 1.4
414

515
### Version 1.4.2

docs/usage/intro.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"\n",
3939
"import numbers\n",
4040
"\n",
41-
"import awkward as ak # at least version 1.2.0rc5\n",
41+
"import awkward as ak # at least v2.0.0 (vector v1.4.* supports awkward v1 and v2 both)\n",
4242
"import numba as nb\n",
4343
"import numpy as np\n",
4444
"import sympy\n",

noxfile.py

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

77
nox.options.sessions = ["lint", "lite", "tests", "doctests"]
88

9+
ALL_PYTHON = ["3.8", "3.9", "3.10", "3.11", "3.12"]
910

1011
DIR = Path(__file__).parent.resolve()
1112

@@ -17,22 +18,22 @@ def lint(session: nox.Session) -> None:
1718
session.run("pre-commit", "run", "--all-files", *session.posargs)
1819

1920

20-
@nox.session
21+
@nox.session(reuse_venv=True)
2122
def pylint(session: nox.Session) -> None:
2223
"""Run pylint."""
2324
session.install("pylint~=2.14.0")
2425
session.install("-e", ".")
2526
session.run("pylint", "src/vector/", *session.posargs)
2627

2728

28-
@nox.session
29+
@nox.session(reuse_venv=True, python=ALL_PYTHON)
2930
def lite(session: nox.Session) -> None:
3031
"""Run the linter."""
3132
session.install("-e", ".[test]")
3233
session.run("pytest", "--ignore", "tests/test_notebooks.py", *session.posargs)
3334

3435

35-
@nox.session(reuse_venv=True)
36+
@nox.session(reuse_venv=True, python=ALL_PYTHON)
3637
def tests(session: nox.Session) -> None:
3738
"""Run the unit and regular tests."""
3839
session.install("-e", ".[awkward,numba,test,test-extras,sympy]")
@@ -44,14 +45,14 @@ def tests(session: nox.Session) -> None:
4445
)
4546

4647

47-
@nox.session(reuse_venv=True)
48+
@nox.session(reuse_venv=True, python=ALL_PYTHON)
4849
def coverage(session: nox.Session) -> None:
4950
"""Run tests and compute coverage."""
5051
session.posargs.append("--cov=vector")
5152
tests(session)
5253

5354

54-
@nox.session(reuse_venv=True)
55+
@nox.session(reuse_venv=True, python=ALL_PYTHON)
5556
def doctests(session: nox.Session) -> None:
5657
"""Run the doctests."""
5758
session.install("-e", ".[awkward,numba,test,test-extras,sympy]")
@@ -61,8 +62,8 @@ def doctests(session: nox.Session) -> None:
6162
@nox.session(reuse_venv=True)
6263
def notebooks(session: nox.Session) -> None:
6364
"""Run the notebook tests"""
64-
session.install("-e", ".[awkward,numba,test,test-extras]", "numba")
65-
session.install("jupyter", "papermill")
65+
session.install("-e", ".[awkward,numba,test,sympy]")
66+
session.install("jupyter")
6667
session.run("pytest", "tests/test_notebooks.py", *session.posargs)
6768

6869

@@ -81,7 +82,7 @@ def docs(session: nox.Session) -> None:
8182
print("Unsupported argument to docs")
8283

8384

84-
@nox.session
85+
@nox.session(reuse_venv=True)
8586
def build(session: nox.Session) -> None:
8687
"""Build an SDist and wheel."""
8788
session.install("build")

pyproject.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ dependencies = [
4646
"packaging>=19",
4747
]
4848
optional-dependencies.awkward = [
49-
"awkward>=1.2",
49+
"awkward>=2",
5050
]
5151
optional-dependencies.dev = [
52-
"awkward>=1.2",
52+
"awkward>=2",
5353
"dask-awkward",
5454
"nox",
5555
"numba>=0.57; python_version<'3.12'",
@@ -60,7 +60,7 @@ optional-dependencies.dev = [
6060
"sympy",
6161
]
6262
optional-dependencies.docs = [
63-
"awkward>=1.2",
63+
"awkward>=2",
6464
"ipykernel",
6565
"myst-parser>0.13",
6666
"nbsphinx",
@@ -76,16 +76,16 @@ optional-dependencies.sympy = [
7676
"sympy",
7777
]
7878
optional-dependencies.test = [
79-
"dask-awkward",
8079
"nox",
8180
"papermill>=2.4",
8281
"pytest>=6",
8382
"pytest-cov>=3",
8483
"pytest-doctestplus",
8584
]
8685
optional-dependencies.test-extras = [
86+
"dask_awkward",
8787
"spark-parser",
88-
"uncompyle6",
88+
'uncompyle6; python_version == "3.8"',
8989
]
9090
urls."Bug Tracker" = "https://github.com/scikit-hep/vector/issues"
9191
urls.Changelog = "https://vector.readthedocs.io/en/latest/changelog.html"

src/vector/__init__.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,13 @@
6060

6161
def _import_awkward() -> None:
6262
awk_version = packaging.version.Version(importlib.metadata.version("awkward"))
63-
if awk_version < packaging.version.Version("1.2.0rc5"):
63+
if awk_version < packaging.version.Version("2.0.0"):
6464
# the only context users will see this message is if they're trying to use vector.awk
6565
# VectorAwkward is still set to None
66-
msg = f"awkward {awk_version} is too old; please upgrade to 1.2.0 or later"
66+
msg = f"awkward {awk_version} is too old; please upgrade to 2.0.0 or later"
6767
raise ImportError(msg)
6868

6969

70-
_is_awkward_v2: bool | None
71-
try:
72-
_is_awkward_v2 = packaging.version.Version(
73-
importlib.metadata.version("awkward")
74-
) >= packaging.version.Version("2.0.0rc1")
75-
except importlib.metadata.PackageNotFoundError:
76-
_is_awkward_v2 = None
77-
7870
try:
7971
import awkward
8072

src/vector/backends/awkward.py

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,33 +1638,17 @@ class MomentumRecord4D(MomentumAwkward4D, ak.Record): # type: ignore[misc]
16381638

16391639
# implementation of behaviors in Numba ########################################
16401640

1641-
if vector._is_awkward_v2:
16421641

1643-
def _lookup_field(record_type: typing.Any, name: str) -> int:
1644-
return record_type.fields.index(name)
1645-
1646-
else:
1647-
1648-
def _lookup_field(record_type: typing.Any, name: str) -> int:
1649-
return record_type.recordlookup.index(name)
1642+
def _lookup_field(record_type: typing.Any, name: str) -> int:
1643+
return record_type.fields.index(name)
16501644

16511645

16521646
def _arraytype_of(awkwardtype: typing.Any, component: str) -> typing.Any:
16531647
import numba
16541648

1655-
if isinstance(
1656-
awkwardtype,
1657-
ak._connect.numba.layout.NumpyArrayType
1658-
if hasattr(ak._connect, "numba") # Awkward v2
1659-
else ak._connect._numba.layout.NumpyArrayType,
1660-
):
1649+
if isinstance(awkwardtype, ak._connect.numba.layout.NumpyArrayType):
16611650
return awkwardtype.arraytype
1662-
elif isinstance(
1663-
awkwardtype,
1664-
ak._connect.numba.layout.IndexedArrayType
1665-
if hasattr(ak._connect, "numba") # Awkward v2
1666-
else ak._connect._numba.layout.IndexedArrayType,
1667-
):
1651+
elif isinstance(awkwardtype, ak._connect.numba.layout.IndexedArrayType):
16681652
return _arraytype_of(awkwardtype.contenttype, component)
16691653
raise numba.TypingError(
16701654
f"vector components like {component!r} must be NumpyArrayType, not {awkwardtype}"
@@ -1947,11 +1931,7 @@ def _numba_lower(
19471931

19481932
vectorcls = sig.return_type.instance_class
19491933

1950-
fields = (
1951-
sig.args[0].arrayviewtype.type.fields
1952-
if vector._is_awkward_v2
1953-
else sig.args[0].arrayviewtype.type.recordlookup
1954-
)
1934+
fields = sig.args[0].arrayviewtype.type.fields
19551935

19561936
if issubclass(vectorcls, (VectorObject2D, VectorObject3D, VectorObject4D)):
19571937
if issubclass(sig.return_type.azimuthaltype.instance_class, AzimuthalXY):

0 commit comments

Comments
 (0)