Skip to content

Commit bff3bf4

Browse files
authored
Drop Python 3.9; test on Python 3.13; drop NumPy 1.21; skip CUDA install (#304)
reviewed at #304
1 parent 3e5fdc0 commit bff3bf4

23 files changed

+114
-185
lines changed

.github/workflows/array-api-tests-dask.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ jobs:
77
uses: ./.github/workflows/array-api-tests.yml
88
with:
99
package-name: dask
10-
package-version: '>= 2024.9.0'
1110
module-name: dask.array
1211
extra-requires: numpy
1312
# Dask is substantially slower then other libraries on unit tests.
@@ -16,3 +15,4 @@ jobs:
1615
# flakiness. Before changes to dask-xfails.txt or dask-skips.txt, please run
1716
# the full test suite with at least 200 examples.
1817
pytest-extra-args: --max-examples=5
18+
python-versions: '[''3.10'', ''3.13'']'

.github/workflows/array-api-tests-numpy-1-21.yml

-11
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Array API Tests (NumPy 1.22)
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
array-api-tests-numpy-1-22:
7+
uses: ./.github/workflows/array-api-tests.yml
8+
with:
9+
package-name: numpy
10+
package-version: '== 1.22.*'
11+
xfails-file-extra: '-1-22'
12+
python-versions: '[''3.10'']'

.github/workflows/array-api-tests-numpy-1-26.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ jobs:
99
package-name: numpy
1010
package-version: '== 1.26.*'
1111
xfails-file-extra: '-1-26'
12+
python-versions: '[''3.10'', ''3.12'']'

.github/workflows/array-api-tests-numpy-dev.yml

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ jobs:
99
package-name: numpy
1010
extra-requires: '--pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple'
1111
xfails-file-extra: '-dev'
12+
python-versions: '[''3.11'', ''3.13'']'
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Array API Tests (NumPy Latest)
1+
name: Array API Tests (NumPy latest)
22

33
on: [push, pull_request]
44

@@ -7,3 +7,4 @@ jobs:
77
uses: ./.github/workflows/array-api-tests.yml
88
with:
99
package-name: numpy
10+
python-versions: '[''3.10'', ''3.13'']'
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Array API Tests (PyTorch Latest)
1+
name: Array API Tests (PyTorch CPU)
22

33
on: [push, pull_request]
44

@@ -7,5 +7,7 @@ jobs:
77
uses: ./.github/workflows/array-api-tests.yml
88
with:
99
package-name: torch
10+
extra-requires: '--index-url https://download.pytorch.org/whl/cpu'
1011
extra-env-vars: |
1112
ARRAY_API_TESTS_SKIP_DTYPES=uint16,uint32,uint64
13+
python-versions: '[''3.10'', ''3.13'']'

.github/workflows/array-api-tests.yml

+15-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
required: false
1717
type: string
1818
default: '>= 0'
19+
python-versions:
20+
required: true
21+
type: string
22+
description: JSON array of Python versions to test against.
1923
pytest-extra-args:
2024
required: false
2125
type: string
@@ -30,7 +34,7 @@ on:
3034
extra-env-vars:
3135
required: false
3236
type: string
33-
description: "Multiline string of environment variables to set for the test run."
37+
description: Multiline string of environment variables to set for the test run.
3438

3539
env:
3640
PYTEST_ARGS: "--max-examples 200 -v -rxXfE --ci ${{ inputs.pytest-extra-args }} --hypothesis-disable-deadline --durations 10"
@@ -39,41 +43,44 @@ jobs:
3943
tests:
4044
runs-on: ubuntu-latest
4145
strategy:
46+
fail-fast: false
4247
matrix:
43-
# Min version of dask we need dropped support for Python 3.9
44-
# There is no numpy git tip for Python 3.9 or 3.10
45-
python-version: ${{ (inputs.package-name == 'dask' && fromJson('[''3.10'', ''3.11'', ''3.12'']')) || (inputs.package-name == 'numpy' && inputs.xfails-file-extra == '-dev' && fromJson('[''3.11'', ''3.12'']')) || fromJson('[''3.9'', ''3.10'', ''3.11'', ''3.12'']') }}
48+
python-version: ${{ fromJson(inputs.python-versions) }}
4649

4750
steps:
4851
- name: Checkout array-api-compat
4952
uses: actions/checkout@v4
5053
with:
5154
path: array-api-compat
55+
5256
- name: Checkout array-api-tests
5357
uses: actions/checkout@v4
5458
with:
5559
repository: data-apis/array-api-tests
5660
submodules: 'true'
5761
path: array-api-tests
62+
5863
- name: Set up Python ${{ matrix.python-version }}
5964
uses: actions/setup-python@v5
6065
with:
6166
python-version: ${{ matrix.python-version }}
67+
6268
- name: Set Extra Environment Variables
6369
# Set additional environment variables if provided
6470
if: inputs.extra-env-vars
6571
run: |
6672
echo "${{ inputs.extra-env-vars }}" >> $GITHUB_ENV
73+
6774
- name: Install dependencies
68-
# NumPy 1.21 doesn't support Python 3.11. There doesn't seem to be a way
69-
# to put this in the numpy 1.21 config file.
70-
if: "! ((matrix.python-version == '3.11' || matrix.python-version == '3.12') && inputs.package-name == 'numpy' && contains(inputs.package-version, '1.21'))"
7175
run: |
7276
python -m pip install --upgrade pip
7377
python -m pip install '${{ inputs.package-name }} ${{ inputs.package-version }}' ${{ inputs.extra-requires }}
7478
python -m pip install -r ${GITHUB_WORKSPACE}/array-api-tests/requirements.txt
79+
80+
- name: Dump pip environment
81+
run: pip freeze
82+
7583
- name: Run the array API testsuite (${{ inputs.package-name }})
76-
if: "! ((matrix.python-version == '3.11' || matrix.python-version == '3.12') && inputs.package-name == 'numpy' && contains(inputs.package-version, '1.21'))"
7784
env:
7885
ARRAY_API_TESTS_MODULE: array_api_compat.${{ inputs.module-name || inputs.package-name }}
7986
ARRAY_API_TESTS_VERSION: 2024.12

.github/workflows/tests.yml

+37-21
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@ jobs:
44
tests:
55
runs-on: ubuntu-latest
66
strategy:
7+
fail-fast: false
78
matrix:
8-
python-version: ['3.9', '3.10', '3.11', '3.12']
9-
numpy-version: ['1.21', '1.26', '2.0', 'dev']
10-
exclude:
11-
- python-version: '3.11'
12-
numpy-version: '1.21'
13-
- python-version: '3.12'
14-
numpy-version: '1.21'
15-
fail-fast: true
9+
include:
10+
- numpy-version: '1.22'
11+
python-version: '3.10'
12+
- numpy-version: '1.26'
13+
python-version: '3.10'
14+
- numpy-version: '1.26'
15+
python-version: '3.12'
16+
- numpy-version: 'latest'
17+
python-version: '3.10'
18+
- numpy-version: 'latest'
19+
python-version: '3.13'
20+
- numpy-version: 'dev'
21+
python-version: '3.11'
22+
- numpy-version: 'dev'
23+
python-version: '3.13'
24+
1625
steps:
1726
- uses: actions/checkout@v4
1827
- uses: actions/setup-python@v5
@@ -21,22 +30,29 @@ jobs:
2130
- name: Install Dependencies
2231
run: |
2332
python -m pip install --upgrade pip
33+
python -m pip install pytest
34+
2435
if [ "${{ matrix.numpy-version }}" == "dev" ]; then
25-
PIP_EXTRA='numpy --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple'
26-
elif [ "${{ matrix.numpy-version }}" == "1.21" ]; then
27-
PIP_EXTRA='numpy==1.21.*'
36+
python -m pip install numpy --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
37+
elif [ "${{ matrix.numpy-version }}" == "1.22" ]; then
38+
python -m pip install 'numpy==1.22.*'
39+
elif [ "${{ matrix.numpy-version }}" == "1.26" ]; then
40+
python -m pip install 'numpy==1.26.*'
2841
else
29-
PIP_EXTRA='numpy==1.26.*'
42+
# Don't `pip install .[dev]` as it would pull in the whole torch cuda stack
43+
python -m pip install array-api-strict dask[array] jax[cpu] numpy sparse
44+
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
45+
if [ "${{ matrix.python-version }}" != "3.13" ]; then
46+
# onnx wheels are not available on Python 3.13 at the moment of writing
47+
python -m pip install ndonnx
48+
fi
3049
fi
3150
32-
python -m pip install .[dev] $PIP_EXTRA
51+
- name: Dump pip environment
52+
run: pip freeze
3353

34-
- name: Run Tests
35-
run: |
36-
if [[ "${{ matrix.numpy-version }}" == "1.21" || "${{ matrix.numpy-version }}" == "dev" ]]; then
37-
PYTEST_EXTRA=(-k "numpy and not jax and not torch and not dask and not sparse")
38-
fi
39-
pytest -v "${PYTEST_EXTRA[@]}"
54+
- name: Test it installs
55+
run: python -m pip install .
4056

41-
# Make sure it installs
42-
python -m pip install .
57+
- name: Run Tests
58+
run: pytest -v

array_api_compat/cupy/_typing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from cupy.cuda.device import Device
1111

1212
if TYPE_CHECKING:
13-
# NumPy 1.x on Python 3.9 and 3.10 fails to parse np.dtype[]
13+
# NumPy 1.x on Python 3.10 fails to parse np.dtype[]
1414
DType = cp.dtype[
1515
cp.intp
1616
| cp.int8

array_api_compat/dask/array/_aliases.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def asarray(
147147
*,
148148
dtype: Optional[DType] = None,
149149
device: Optional[Device] = None,
150-
copy: Optional[Union[bool, np._CopyMode]] = None,
150+
copy: Optional[bool] = None,
151151
**kwargs,
152152
) -> Array:
153153
"""

array_api_compat/numpy/_aliases.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,12 @@ def asarray(
9999
"""
100100
_helpers._check_device(np, device)
101101

102-
if hasattr(np, '_CopyMode'):
103-
if copy is None:
104-
copy = np._CopyMode.IF_NEEDED
105-
elif copy is False:
106-
copy = np._CopyMode.NEVER
107-
elif copy is True:
108-
copy = np._CopyMode.ALWAYS
109-
else:
110-
# Not present in older NumPys. In this case, we cannot really support
111-
# copy=False.
112-
if copy is False:
113-
raise NotImplementedError("asarray(copy=False) requires a newer version of NumPy.")
102+
if copy is None:
103+
copy = np._CopyMode.IF_NEEDED
104+
elif copy is False:
105+
copy = np._CopyMode.NEVER
106+
elif copy is True:
107+
copy = np._CopyMode.ALWAYS
114108

115109
return np.array(obj, copy=copy, dtype=dtype, **kwargs)
116110

array_api_compat/numpy/_typing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
Device = Literal["cpu"]
1212
if TYPE_CHECKING:
13-
# NumPy 1.x on Python 3.9 and 3.10 fails to parse np.dtype[]
13+
# NumPy 1.x on Python 3.10 fails to parse np.dtype[]
1414
DType = np.dtype[
1515
np.intp
1616
| np.int8

docs/supported-array-libraries.md

+3-14
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,16 @@ deviations from the standard should be noted:
3636
50](https://numpy.org/neps/nep-0050-scalar-promotion.html) and
3737
https://github.com/numpy/numpy/issues/22341)
3838

39-
- `asarray()` does not support `copy=False`.
40-
4139
- Functions which are not wrapped may not have the same type annotations
4240
as the spec.
4341

4442
- Functions which are not wrapped may not use positional-only arguments.
4543

46-
The minimum supported NumPy version is 1.21. However, this older version of
44+
The minimum supported NumPy version is 1.22. However, this older version of
4745
NumPy has a few issues:
4846

4947
- `unique_*` will not compare nans as unequal.
50-
- `finfo()` has no `smallest_normal`.
5148
- No `from_dlpack` or `__dlpack__`.
52-
- `argmax()` and `argmin()` do not have `keepdims`.
53-
- `qr()` doesn't support matrix stacks.
54-
- `asarray()` doesn't support `copy=True` (as noted above, `copy=False` is not
55-
supported even in the latest NumPy).
5649
- Type promotion behavior will be value based for 0-D arrays (and there is no
5750
`NPY_PROMOTION_STATE=weak` to disable this).
5851

@@ -72,8 +65,8 @@ version.
7265
attribute in the spec. Use the {func}`~.size()` helper function as a
7366
portable workaround.
7467

75-
- PyTorch does not have unsigned integer types other than `uint8`, and no
76-
attempt is made to implement them here.
68+
- PyTorch has incomplete support for unsigned integer types other
69+
than `uint8`, and no attempt is made to implement them here.
7770

7871
- PyTorch has type promotion semantics that differ from the array API
7972
specification for 0-D tensor objects. The array functions in this wrapper
@@ -100,8 +93,6 @@ version.
10093
- As with NumPy, type annotations and positional-only arguments may not
10194
exactly match the spec for functions that are not wrapped at all.
10295

103-
The minimum supported PyTorch version is 1.13.
104-
10596
(jax-support)=
10697
## [JAX](https://jax.readthedocs.io/en/latest/)
10798

@@ -131,8 +122,6 @@ For `linalg`, several methods are missing, for example:
131122
- `matrix_rank`
132123
Other methods may only be partially implemented or return incorrect results at times.
133124

134-
The minimum supported Dask version is 2023.12.0.
135-
136125
(sparse-support)=
137126
## [Sparse](https://sparse.pydata.org/en/stable/)
138127

0 commit comments

Comments
 (0)