Skip to content

Commit a1f19d5

Browse files
committed
Drop Python 3.9; Test on Python 3.13; drop NumPy 1.21; skip CUDA install
1 parent 3e5fdc0 commit a1f19d5

15 files changed

+79
-77
lines changed

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 12 additions & 0 deletions
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'', ''3.12'']'

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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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'']'

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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'']'

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ jobs:
99
package-name: torch
1010
extra-env-vars: |
1111
ARRAY_API_TESTS_SKIP_DTYPES=uint16,uint32,uint64
12+
python-versions: '[''3.10'', ''3.13'']'

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

Lines changed: 6 additions & 8 deletions
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"
@@ -40,9 +44,7 @@ jobs:
4044
runs-on: ubuntu-latest
4145
strategy:
4246
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'']') }}
47+
python-version: ${{ fromJson(inputs.python-versions) }}
4648

4749
steps:
4850
- name: Checkout array-api-compat
@@ -65,15 +67,11 @@ jobs:
6567
run: |
6668
echo "${{ inputs.extra-env-vars }}" >> $GITHUB_ENV
6769
- 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'))"
7170
run: |
7271
python -m pip install --upgrade pip
7372
python -m pip install '${{ inputs.package-name }} ${{ inputs.package-version }}' ${{ inputs.extra-requires }}
7473
python -m pip install -r ${GITHUB_WORKSPACE}/array-api-tests/requirements.txt
7574
- 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'))"
7775
env:
7876
ARRAY_API_TESTS_MODULE: array_api_compat.${{ inputs.module-name || inputs.package-name }}
7977
ARRAY_API_TESTS_VERSION: 2024.12

.github/workflows/tests.yml

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,25 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
python-version: ['3.9', '3.10', '3.11', '3.12']
9-
numpy-version: ['1.21', '1.26', '2.0', 'dev']
10-
exclude:
8+
include:
9+
- python-version: '3.10'
10+
numpy-version: '1.22'
11+
- python-version: '3.10'
12+
numpy-version: '1.26'
13+
- python-version: '3.10'
14+
numpy-version: 'latest'
1115
- python-version: '3.11'
12-
numpy-version: '1.21'
16+
numpy-version: 'dev'
1317
- python-version: '3.12'
14-
numpy-version: '1.21'
15-
fail-fast: true
18+
numpy-version: '1.22'
19+
- python-version: '3.12'
20+
numpy-version: '1.26'
21+
- python-version: '3.13'
22+
numpy-version: 'latest'
23+
- python-version: '3.13'
24+
numpy-version: 'dev'
25+
26+
fail-fast: false
1627
steps:
1728
- uses: actions/checkout@v4
1829
- uses: actions/setup-python@v5
@@ -22,21 +33,27 @@ jobs:
2233
run: |
2334
python -m pip install --upgrade pip
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 pytest
37+
python -m pip install numpy --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
38+
elif [ "${{ matrix.numpy-version }}" == "1.22" ]; then
39+
python -m pip install pytest numpy==1.22.*
40+
elif [ "${{ matrix.numpy-version }}" == "1.26" ]; then
41+
python -m pip install pytest numpy==1.26.*
2842
else
29-
PIP_EXTRA='numpy==1.26.*'
43+
# Don't pip install .[dev] as it would pull in the whole torch cuda stack
44+
python -m pip install \
45+
array-api-strict \
46+
dask[array] \
47+
jax[cpu] \
48+
numpy \
49+
pytest \
50+
sparse \
51+
ndonnx \
52+
python -m -pip install torch --index-url https://download.pytorch.org/whl/cpu
3053
fi
3154
32-
python -m pip install .[dev] $PIP_EXTRA
55+
- name: Test it installs
56+
run: python -m pip install .
3357

3458
- 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[@]}"
40-
41-
# Make sure it installs
42-
python -m pip install .
59+
run: pytest -v

array_api_compat/dask/array/_aliases.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 12 deletions
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

docs/supported-array-libraries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ deviations from the standard should be noted:
4343

4444
- Functions which are not wrapped may not use positional-only arguments.
4545

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

4949
- `unique_*` will not compare nans as unequal.

numpy-1-21-xfails.txt renamed to numpy-1-22-xfails.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(isfinite(x1_i) and
3939
# https://github.com/numpy/numpy/issues/21213
4040
array_api_tests/meta/test_hypothesis_helpers.py::test_symmetric_matrices
4141

42-
# NumPy 1.21 specific XFAILS
42+
# NumPy 1.22 specific XFAILS
4343
############################
4444

4545
# finfo has no smallest_normal
@@ -69,7 +69,7 @@ array_api_tests/test_searching_functions.py::test_argmin
6969
array_api_tests/test_signatures.py::test_func_signature[argmax]
7070
array_api_tests/test_signatures.py::test_func_signature[argmin]
7171

72-
# NumPy 1.21 doesn't support NPY_PROMOTION_STATE=weak, so many tests fail with
72+
# NumPy 1.22 doesn't support NPY_PROMOTION_STATE=weak, so many tests fail with
7373
# type promotion issues
7474
array_api_tests/test_manipulation_functions.py::test_concat
7575
array_api_tests/test_operators_and_elementwise_functions.py::test_add[__add__(x, s)]

pyproject.toml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ name = "array-api-compat"
77
dynamic = ["version"]
88
description = "A wrapper around NumPy and other array libraries to make them compatible with the Array API standard"
99
readme = "README.md"
10-
requires-python = ">=3.9"
10+
requires-python = ">=3.10"
1111
license = "MIT"
1212
authors = [{name = "Consortium for Python Data API Standards"}]
1313
classifiers = [
1414
"Operating System :: OS Independent",
1515
"Programming Language :: Python :: 3",
16-
"Programming Language :: Python :: 3.9",
1716
"Programming Language :: Python :: 3.10",
1817
"Programming Language :: Python :: 3.11",
1918
"Programming Language :: Python :: 3.12",
@@ -24,11 +23,14 @@ classifiers = [
2423

2524
[project.optional-dependencies]
2625
cupy = ["cupy"]
27-
dask = ["dask"]
26+
dask = ["dask>=2024.9.0"]
2827
jax = ["jax"]
29-
numpy = ["numpy"]
28+
# Note: array-api-compat follows scikit-learn minimum dependencies, which support
29+
# much older versions of NumPy than what SPEC0 recommends.
30+
numpy = ["numpy>=1.22"]
3031
pytorch = ["torch"]
3132
sparse = ["sparse>=0.15.1"]
33+
ndonnx = ["ndonnx"]
3234
docs = [
3335
"furo",
3436
"linkify-it-py",
@@ -39,13 +41,13 @@ docs = [
3941
]
4042
dev = [
4143
"array-api-strict",
42-
"dask[array]",
44+
"dask[array]>=2024.9.0",
4345
"jax[cpu]",
44-
"numpy",
46+
"numpy>=1.22",
4547
"pytest",
4648
"torch",
4749
"sparse>=0.15.1",
48-
"ndonnx; python_version>=\"3.10\""
50+
"ndonnx"
4951
]
5052

5153
[project.urls]
@@ -59,17 +61,6 @@ version = {attr = "array_api_compat.__version__"}
5961
include = ["array_api_compat*"]
6062
namespaces = false
6163

62-
[toolint]
63-
preview = true
64-
select = [
65-
# Defaults
66-
"E4", "E7", "E9", "F",
67-
# Undefined export
68-
"F822",
69-
# Useless import alias
70-
"PLC0414"
71-
]
72-
7364
ignore = [
7465
# Module import not at top of file
7566
"E402",

tests/test_common.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,7 @@ def test_asarray_copy(library):
276276
is_lib_func = globals()[is_array_functions[library]]
277277
all = xp.all if library != 'dask.array' else lambda x: xp.all(x).compute()
278278

279-
if library == 'numpy' and xp.__version__[0] < '2' and not hasattr(np, "_CopyMode"):
280-
supports_copy_false_other_ns = False
281-
supports_copy_false_same_ns = False
282-
elif library == 'cupy':
279+
if library == 'cupy':
283280
supports_copy_false_other_ns = False
284281
supports_copy_false_same_ns = False
285282
elif library == 'dask.array':

0 commit comments

Comments
 (0)