Skip to content

Commit d126ce8

Browse files
committed
🧙 split numpy 1 and 2 integration tests with black voodoo magic
1 parent 0ad8e00 commit d126ce8

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

‎.github/workflows/ci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ jobs:
7070
strategy:
7171
fail-fast: false
7272
matrix:
73-
# numpy<2 does not support the array api
74-
numpy-version: ["2.0.0", "2.1.3", "2.2.6", "2.3.1"]
73+
numpy-version: ["1.25.0", "1.26.4", "2.0.2", "2.1.3", "2.2.6", "2.3.1"]
7574

7675
steps:
7776
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -81,6 +80,12 @@ jobs:
8180
python-version: "3.11"
8281
activate-environment: true
8382

83+
- name: get major numpy version
84+
id: numpy-major
85+
run: |
86+
version=$(echo ${{ matrix.numpy-version }} | cut -c 1-7)
87+
echo "::set-output name=version::$version"
88+
8489
- name: install deps
8590
run: |
8691
uv sync --no-editable --group=mypy
@@ -90,10 +95,10 @@ jobs:
9095
- name: mypy
9196
run: >
9297
uv run --no-sync --active
93-
mypy --tb --no-incremental --cache-dir=/dev/null tests/integration/test_numpy.pyi
98+
mypy --tb --no-incremental --cache-dir=/dev/null
99+
tests/integration/test_numpy${{ steps.numpy-major.outputs.version }}.pyi
94100
95101
# TODO: (based)pyright
96102

97-
# TODO: integration tests for array-api-compat + numpy<2
98103
# TODO: integration tests for array-api-strict
99104
# TODO: integration tests for 3rd party libs such as cupy, pytorch, tensorflow, dask, etc.

‎tests/integration/test_numpy1.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from typing import Any
2+
3+
import numpy.array_api as np
4+
5+
import array_api_typing as xpt
6+
7+
###
8+
# Ensure that `np.ndarray` instances are assignable to `xpt.HasArrayNamespace`.
9+
10+
arr: np.Array
11+
arr_namespace: xpt.HasArrayNamespace[Any] = arr

‎tests/integration/test_numpy.pyi renamed to ‎tests/integration/test_numpy2.pyi

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
from typing import Any, TypeVar
1+
from typing import Any
22

33
import numpy.typing as npt
44

55
import array_api_typing as xpt
66

7-
_T = TypeVar("_T", bound=npt.NDArray[Any])
8-
9-
def get_namespace(obj: xpt.HasArrayNamespace[_T], /) -> _T: ...
10-
117
###
128
# Ensure that `np.ndarray` instances are assignable to `xpt.HasArrayNamespace`.
139

0 commit comments

Comments
 (0)