Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/array-api-tests-dask.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jobs:
uses: ./.github/workflows/array-api-tests.yml
with:
package-name: dask
package-version: '>= 2024.9.0'
module-name: dask.array
extra-requires: numpy
# Dask is substantially slower then other libraries on unit tests.
Expand All @@ -16,3 +15,4 @@ jobs:
# flakiness. Before changes to dask-xfails.txt or dask-skips.txt, please run
# the full test suite with at least 200 examples.
pytest-extra-args: --max-examples=5
python-versions: '[''3.10'', ''3.13'']'
11 changes: 0 additions & 11 deletions .github/workflows/array-api-tests-numpy-1-21.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/array-api-tests-numpy-1-22.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Array API Tests (NumPy 1.22)

on: [push, pull_request]

jobs:
array-api-tests-numpy-1-22:
uses: ./.github/workflows/array-api-tests.yml
with:
package-name: numpy
package-version: '== 1.22.*'
xfails-file-extra: '-1-22'
python-versions: '[''3.10'']'
1 change: 1 addition & 0 deletions .github/workflows/array-api-tests-numpy-1-26.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ jobs:
package-name: numpy
package-version: '== 1.26.*'
xfails-file-extra: '-1-26'
python-versions: '[''3.10'', ''3.12'']'
1 change: 1 addition & 0 deletions .github/workflows/array-api-tests-numpy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ jobs:
package-name: numpy
extra-requires: '--pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple'
xfails-file-extra: '-dev'
python-versions: '[''3.11'', ''3.13'']'
3 changes: 2 additions & 1 deletion .github/workflows/array-api-tests-numpy-latest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Array API Tests (NumPy Latest)
name: Array API Tests (NumPy latest)

on: [push, pull_request]

Expand All @@ -7,3 +7,4 @@ jobs:
uses: ./.github/workflows/array-api-tests.yml
with:
package-name: numpy
python-versions: '[''3.10'', ''3.13'']'
4 changes: 3 additions & 1 deletion .github/workflows/array-api-tests-torch.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Array API Tests (PyTorch Latest)
name: Array API Tests (PyTorch CPU)

on: [push, pull_request]

Expand All @@ -7,5 +7,7 @@ jobs:
uses: ./.github/workflows/array-api-tests.yml
with:
package-name: torch
extra-requires: '--index-url https://download.pytorch.org/whl/cpu'
extra-env-vars: |
ARRAY_API_TESTS_SKIP_DTYPES=uint16,uint32,uint64
python-versions: '[''3.10'', ''3.13'']'
22 changes: 14 additions & 8 deletions .github/workflows/array-api-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ on:
required: false
type: string
default: '>= 0'
python-versions:
required: true
type: string
description: JSON array of Python versions to test against.
pytest-extra-args:
required: false
type: string
Expand All @@ -30,7 +34,7 @@ on:
extra-env-vars:
required: false
type: string
description: "Multiline string of environment variables to set for the test run."
description: Multiline string of environment variables to set for the test run.

env:
PYTEST_ARGS: "--max-examples 200 -v -rxXfE --ci ${{ inputs.pytest-extra-args }} --hypothesis-disable-deadline --durations 10"
Expand All @@ -40,40 +44,42 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# Min version of dask we need dropped support for Python 3.9
# There is no numpy git tip for Python 3.9 or 3.10
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'']') }}
python-version: ${{ fromJson(inputs.python-versions) }}

steps:
- name: Checkout array-api-compat
uses: actions/checkout@v4
with:
path: array-api-compat

- name: Checkout array-api-tests
uses: actions/checkout@v4
with:
repository: data-apis/array-api-tests
submodules: 'true'
path: array-api-tests

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Set Extra Environment Variables
# Set additional environment variables if provided
if: inputs.extra-env-vars
run: |
echo "${{ inputs.extra-env-vars }}" >> $GITHUB_ENV

- name: Install dependencies
# NumPy 1.21 doesn't support Python 3.11. There doesn't seem to be a way
# to put this in the numpy 1.21 config file.
if: "! ((matrix.python-version == '3.11' || matrix.python-version == '3.12') && inputs.package-name == 'numpy' && contains(inputs.package-version, '1.21'))"
run: |
python -m pip install --upgrade pip
python -m pip install '${{ inputs.package-name }} ${{ inputs.package-version }}' ${{ inputs.extra-requires }}
python -m pip install -r ${GITHUB_WORKSPACE}/array-api-tests/requirements.txt

- name: Dump pip environment
run: pip freeze

- name: Run the array API testsuite (${{ inputs.package-name }})
if: "! ((matrix.python-version == '3.11' || matrix.python-version == '3.12') && inputs.package-name == 'numpy' && contains(inputs.package-version, '1.21'))"
env:
ARRAY_API_TESTS_MODULE: array_api_compat.${{ inputs.module-name || inputs.package-name }}
ARRAY_API_TESTS_VERSION: 2024.12
Expand Down
58 changes: 37 additions & 21 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,23 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
numpy-version: ['1.21', '1.26', '2.0', 'dev']
exclude:
- python-version: '3.11'
numpy-version: '1.21'
- python-version: '3.12'
numpy-version: '1.21'
fail-fast: true
include:
- numpy-version: '1.22'
python-version: '3.10'
- numpy-version: '1.26'
python-version: '3.10'
- numpy-version: '1.26'
python-version: '3.12'
- numpy-version: 'latest'
python-version: '3.10'
- numpy-version: 'latest'
python-version: '3.13'
- numpy-version: 'dev'
python-version: '3.11'
- numpy-version: 'dev'
python-version: '3.13'

fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -21,22 +30,29 @@ jobs:
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest

if [ "${{ matrix.numpy-version }}" == "dev" ]; then
PIP_EXTRA='numpy --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple'
elif [ "${{ matrix.numpy-version }}" == "1.21" ]; then
PIP_EXTRA='numpy==1.21.*'
python -m pip install numpy --pre --extra-index-url https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
elif [ "${{ matrix.numpy-version }}" == "1.22" ]; then
python -m pip install 'numpy==1.22.*'
elif [ "${{ matrix.numpy-version }}" == "1.26" ]; then
python -m pip install 'numpy==1.26.*'
else
PIP_EXTRA='numpy==1.26.*'
# Don't `pip install .[dev]` as it would pull in the whole torch cuda stack
python -m pip install array-api-strict dask[array] jax[cpu] numpy sparse
python -m pip install torch --index-url https://download.pytorch.org/whl/cpu
if [ "${{ matrix.python-version }}" != "3.13" ]; then
# onnx wheels are not available on Python 3.13 at the moment of writing
python -m pip install ndonnx
fi
fi

python -m pip install .[dev] $PIP_EXTRA
- name: Dump pip environment
run: pip freeze

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

# Make sure it installs
python -m pip install .
- name: Run Tests
run: pytest -v
2 changes: 1 addition & 1 deletion array_api_compat/cupy/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from cupy.cuda.device import Device

if TYPE_CHECKING:
# NumPy 1.x on Python 3.9 and 3.10 fails to parse np.dtype[]
# NumPy 1.x on Python 3.10 fails to parse np.dtype[]
DType = cp.dtype[
cp.intp
| cp.int8
Expand Down
2 changes: 1 addition & 1 deletion array_api_compat/dask/array/_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def asarray(
*,
dtype: Optional[DType] = None,
device: Optional[Device] = None,
copy: Optional[Union[bool, np._CopyMode]] = None,
copy: Optional[bool] = None,
**kwargs,
) -> Array:
"""
Expand Down
18 changes: 6 additions & 12 deletions array_api_compat/numpy/_aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,12 @@ def asarray(
"""
_helpers._check_device(np, device)

if hasattr(np, '_CopyMode'):
if copy is None:
copy = np._CopyMode.IF_NEEDED
elif copy is False:
copy = np._CopyMode.NEVER
elif copy is True:
copy = np._CopyMode.ALWAYS
else:
# Not present in older NumPys. In this case, we cannot really support
# copy=False.
if copy is False:
raise NotImplementedError("asarray(copy=False) requires a newer version of NumPy.")
if copy is None:
copy = np._CopyMode.IF_NEEDED
elif copy is False:
copy = np._CopyMode.NEVER
elif copy is True:
copy = np._CopyMode.ALWAYS

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

Expand Down
2 changes: 1 addition & 1 deletion array_api_compat/numpy/_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

Device = Literal["cpu"]
if TYPE_CHECKING:
# NumPy 1.x on Python 3.9 and 3.10 fails to parse np.dtype[]
# NumPy 1.x on Python 3.10 fails to parse np.dtype[]
DType = np.dtype[
np.intp
| np.int8
Expand Down
17 changes: 3 additions & 14 deletions docs/supported-array-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,16 @@ deviations from the standard should be noted:
50](https://numpy.org/neps/nep-0050-scalar-promotion.html) and
https://github.com/numpy/numpy/issues/22341)

- `asarray()` does not support `copy=False`.

- Functions which are not wrapped may not have the same type annotations
as the spec.

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

The minimum supported NumPy version is 1.21. However, this older version of
The minimum supported NumPy version is 1.22. However, this older version of
NumPy has a few issues:

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

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

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

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

The minimum supported PyTorch version is 1.13.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not advertise what you don't test.


(jax-support)=
## [JAX](https://jax.readthedocs.io/en/latest/)

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

The minimum supported Dask version is 2023.12.0.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not advertise what you don't test. Also helplessly obsolete; we know for sure that less than 2024.9.0 won't work.


(sparse-support)=
## [Sparse](https://sparse.pydata.org/en/stable/)

Expand Down
Loading
Loading