Skip to content

Commit 5d883a8

Browse files
authored
Merge pull request #244 from honno/ci-updates
CI updates
2 parents 5811393 + 526c2d4 commit 5d883a8

35 files changed

+122
-145
lines changed

Diff for: .github/workflows/numpy.yml renamed to .github/workflows/test.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: NumPy Array API
1+
name: Test Array API Strict
22

33
on: [push, pull_request]
44

@@ -22,10 +22,12 @@ jobs:
2222
- name: Install dependencies
2323
run: |
2424
python -m pip install --upgrade pip
25-
python -m pip install numpy==1.26.2
25+
python -m pip install array-api-strict
2626
python -m pip install -r requirements.txt
2727
- name: Run the test suite
2828
env:
29-
ARRAY_API_TESTS_MODULE: numpy.array_api
29+
ARRAY_API_TESTS_MODULE: array_api_strict
3030
run: |
31-
pytest -v -rxXfE --ci --skips-file numpy-skips.txt
31+
pytest -v -rxXfE --skips-file array-api-strict-skips.txt array_api_tests/
32+
# We also have internal tests that isn't really necessary for adopters
33+
pytest -v -rxXfE meta_tests/

Diff for: README.md

+3-9
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ issues](https://github.com/data-apis/array-api-tests/issues/) to us.
138138

139139
## Running on CI
140140

141-
See our existing [GitHub Actions workflow for
142-
Numpy](https://github.com/data-apis/array-api-tests/blob/master/.github/workflows/numpy.yml)
143-
for an example of using the test suite on CI.
141+
See our existing [GitHub Actions workflow for `array-api-strict`](https://github.com/data-apis/array-api-tests/blob/master/.github/workflows/test.yml)
142+
for an example of using the test suite on CI. Note [`array-api-strict`](https://github.com/data-apis/array-api-strict)
143+
is an implementation of the array API that uses NumPy under the hood.
144144

145145
### Releases
146146

@@ -161,12 +161,6 @@ You can specify the API version to use when testing via the
161161
array module's `__array_api_version__` value, and if that attribute doesn't
162162
exist then we fallback to `"2021.12"`.
163163

164-
#### CI flag
165-
166-
Use the `--ci` flag to run only the primary and special cases tests. You can
167-
ignore the other test cases as they are redundant for the purposes of checking
168-
compliance.
169-
170164
#### Data-dependent shapes
171165

172166
Use the `--disable-data-dependent-shapes` flag to skip testing functions which have

Diff for: array-api-strict-skips.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Known special case issue in NumPy. Not worth working around here
2+
# https://github.com/numpy/numpy/issues/21213
3+
array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -infinity and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +infinity]
4+
array_api_tests/test_special_cases.py::test_iop[__ipow__(x1_i is -0 and x2_i > 0 and not (x2_i.is_integer() and x2_i % 2 == 1)) -> +0]
5+
6+
# The test suite is incorrectly checking sums that have loss of significance
7+
# (https://github.com/data-apis/array-api-tests/issues/168)
8+
array_api_tests/test_statistical_functions.py::test_sum

Diff for: array_api_tests/pytest_helpers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ def assert_array_elements(
485485
>>> assert xp.all(out == x)
486486
487487
"""
488-
# __tracebackhide__ = True
488+
__tracebackhide__ = True
489489
dh.result_type(out.dtype, expected.dtype) # sanity check
490490
assert_shape(func_name, out_shape=out.shape, expected=expected.shape, kw=kw) # sanity check
491491
f_func = f"[{func_name}({fmt_kw(kw)})]"

Diff for: array_api_tests/test_array_object.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
from . import xp as _xp
1717
from .typing import DataType, Index, Param, Scalar, ScalarType, Shape
1818

19-
pytestmark = pytest.mark.ci
20-
2119

2220
def scalar_objects(
2321
dtype: DataType, shape: Shape
@@ -107,6 +105,7 @@ def test_getitem(shape, dtype, data):
107105
ph.assert_array_elements("__getitem__", out=out, expected=expected)
108106

109107

108+
@pytest.mark.unvectorized
110109
@given(
111110
shape=hh.shapes(),
112111
dtypes=hh.oneway_promotable_dtypes(dh.all_dtypes),
@@ -154,6 +153,7 @@ def test_setitem(shape, dtypes, data):
154153
)
155154

156155

156+
@pytest.mark.unvectorized
157157
@pytest.mark.data_dependent_shapes
158158
@given(hh.shapes(), st.data())
159159
def test_getitem_masking(shape, data):
@@ -199,6 +199,7 @@ def test_getitem_masking(shape, data):
199199
)
200200

201201

202+
@pytest.mark.unvectorized
202203
@given(hh.shapes(), st.data())
203204
def test_setitem_masking(shape, data):
204205
x = data.draw(hh.arrays(xps.scalar_dtypes(), shape=shape), label="x")

Diff for: array_api_tests/test_constants.py

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
from . import xp
88
from .typing import Array
99

10-
pytestmark = pytest.mark.ci
11-
1210

1311
def assert_scalar_float(name: str, c: Any):
1412
assert isinstance(c, SupportsFloat), f"{name}={c!r} does not look like a float"

Diff for: array_api_tests/test_creation_functions.py

-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from itertools import count
44
from typing import Iterator, NamedTuple, Union
55

6-
import pytest
76
from hypothesis import assume, given, note
87
from hypothesis import strategies as st
98

@@ -15,8 +14,6 @@
1514
from . import xps
1615
from .typing import DataType, Scalar
1716

18-
pytestmark = pytest.mark.ci
19-
2017

2118
class frange(NamedTuple):
2219
start: float

Diff for: array_api_tests/test_data_type_functions.py

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
from . import xp as _xp
1515
from .typing import DataType
1616

17-
pytestmark = pytest.mark.ci
18-
1917

2018
# TODO: test with complex dtypes
2119
def non_complex_dtypes():

Diff for: array_api_tests/test_fft.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from . import xp
1818

1919
pytestmark = [
20-
pytest.mark.ci,
2120
pytest.mark.xp_extension("fft"),
2221
pytest.mark.min_version("2022.12"),
2322
]

Diff for: array_api_tests/test_has_names.py

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
from .stubs import (array_attributes, array_methods, category_to_funcs,
1010
extension_to_funcs, EXTENSIONS)
1111

12-
pytestmark = pytest.mark.ci
13-
1412
has_name_params = []
1513
for ext, stubs in extension_to_funcs.items():
1614
for stub in stubs:

Diff for: array_api_tests/test_indexing_functions.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
from . import shape_helpers as sh
1010
from . import xps
1111

12-
pytestmark = pytest.mark.ci
13-
1412

13+
@pytest.mark.unvectorized
1514
@pytest.mark.min_version("2022.12")
1615
@given(
1716
x=hh.arrays(xps.scalar_dtypes(), hh.shapes(min_dims=1, min_side=1)),

Diff for: array_api_tests/test_linalg.py

-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
from . import _array_module as xp
4444
from ._array_module import linalg
4545

46-
pytestmark = pytest.mark.ci
47-
4846
def assert_equal(x, y, msg_extra=None):
4947
extra = '' if not msg_extra else f' ({msg_extra})'
5048
if x.dtype in dh.all_float_dtypes:

Diff for: array_api_tests/test_manipulation_functions.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
from . import xps
1515
from .typing import Array, Shape
1616

17-
pytestmark = pytest.mark.ci
18-
1917
MAX_SIDE = hh.MAX_ARRAY_SIZE // 64
2018
MAX_DIMS = min(hh.MAX_ARRAY_SIZE // MAX_SIDE, 32) # NumPy only supports up to 32 dims
2119

@@ -121,6 +119,7 @@ def test_concat(dtypes, base_shape, data):
121119
)
122120

123121

122+
@pytest.mark.unvectorized
124123
@given(
125124
x=hh.arrays(dtype=xps.scalar_dtypes(), shape=shared_shapes()),
126125
axis=shared_shapes().flatmap(
@@ -149,6 +148,7 @@ def test_expand_dims(x, axis):
149148
)
150149

151150

151+
@pytest.mark.unvectorized
152152
@given(
153153
x=hh.arrays(
154154
dtype=xps.scalar_dtypes(), shape=hh.shapes(min_side=1).filter(lambda s: 1 in s)
@@ -186,6 +186,7 @@ def test_squeeze(x, data):
186186
assert_array_ndindex("squeeze", x, x_indices=sh.ndindex(x.shape), out=out, out_indices=sh.ndindex(out.shape))
187187

188188

189+
@pytest.mark.unvectorized
189190
@given(
190191
x=hh.arrays(dtype=xps.scalar_dtypes(), shape=hh.shapes()),
191192
data=st.data(),
@@ -210,6 +211,7 @@ def test_flip(x, data):
210211
out_indices=reverse_indices, kw=kw)
211212

212213

214+
@pytest.mark.unvectorized
213215
@given(
214216
x=hh.arrays(dtype=xps.scalar_dtypes(), shape=shared_shapes(min_dims=1)),
215217
axes=shared_shapes(min_dims=1).flatmap(
@@ -250,6 +252,7 @@ def reshape_shapes(draw, shape):
250252
return tuple(rshape)
251253

252254

255+
@pytest.mark.unvectorized
253256
@pytest.mark.skip("flaky") # TODO: fix!
254257
@given(
255258
x=hh.arrays(dtype=xps.scalar_dtypes(), shape=hh.shapes(max_side=MAX_SIDE)),
@@ -282,6 +285,7 @@ def roll_ndindex(shape: Shape, shifts: Tuple[int], axes: Tuple[int]) -> Iterator
282285
yield tuple((i + sh) % si for i, sh, si in zip(idx, all_shifts, shape))
283286

284287

288+
@pytest.mark.unvectorized
285289
@given(hh.arrays(dtype=xps.scalar_dtypes(), shape=shared_shapes()), st.data())
286290
def test_roll(x, data):
287291
shift_strat = st.integers(-hh.MAX_ARRAY_SIZE, hh.MAX_ARRAY_SIZE)
@@ -321,6 +325,7 @@ def test_roll(x, data):
321325
assert_array_ndindex("roll", x, x_indices=sh.ndindex(x.shape), out=out, out_indices=shifted_indices, kw=kw)
322326

323327

328+
@pytest.mark.unvectorized
324329
@given(
325330
shape=shared_shapes(min_dims=1),
326331
dtypes=hh.mutually_promotable_dtypes(None),

Diff for: array_api_tests/test_operators_and_elementwise_functions.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
from . import xps
2222
from .typing import Array, DataType, Param, Scalar, ScalarType, Shape
2323

24-
pytestmark = pytest.mark.ci
24+
25+
pytestmark = pytest.mark.unvectorized
2526

2627

2728
def all_integer_dtypes() -> st.SearchStrategy[DataType]:
@@ -457,7 +458,7 @@ class UnaryParamContext(NamedTuple):
457458

458459
@property
459460
def id(self) -> str:
460-
return f"{self.func_name}"
461+
return self.func_name
461462

462463
def __repr__(self):
463464
return f"UnaryParamContext(<{self.id}>)"

Diff for: array_api_tests/test_searching_functions.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
from . import shape_helpers as sh
1212
from . import xps
1313

14-
pytestmark = pytest.mark.ci
14+
15+
pytestmark = pytest.mark.unvectorized
1516

1617

1718
@given(

Diff for: array_api_tests/test_set_functions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from . import shape_helpers as sh
1414
from . import xps
1515

16-
pytestmark = [pytest.mark.ci, pytest.mark.data_dependent_shapes]
16+
pytestmark = [pytest.mark.data_dependent_shapes, pytest.mark.unvectorized]
1717

1818

1919
@given(hh.arrays(dtype=xps.scalar_dtypes(), shape=hh.shapes(min_side=1)))

Diff for: array_api_tests/test_signatures.py

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ def squeeze(x, /, axis):
3333
from . import xp
3434
from .stubs import array_methods, category_to_funcs, extension_to_funcs, name_to_func
3535

36-
pytestmark = pytest.mark.ci
37-
3836
ParameterKind = Literal[
3937
Parameter.POSITIONAL_ONLY,
4038
Parameter.VAR_POSITIONAL,

Diff for: array_api_tests/test_sorting_functions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
from . import xps
1515
from .typing import Scalar, Shape
1616

17-
pytestmark = pytest.mark.ci
18-
1917

2018
def assert_scalar_in_set(
2119
func_name: str,
@@ -32,6 +30,7 @@ def assert_scalar_in_set(
3230

3331

3432
# TODO: Test with signed zeros and NaNs (and ignore them somehow)
33+
@pytest.mark.unvectorized
3534
@given(
3635
x=hh.arrays(
3736
dtype=xps.real_dtypes(),
@@ -91,6 +90,7 @@ def test_argsort(x, data):
9190
)
9291

9392

93+
@pytest.mark.unvectorized
9494
# TODO: Test with signed zeros and NaNs (and ignore them somehow)
9595
@given(
9696
x=hh.arrays(

Diff for: array_api_tests/test_special_cases.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
from . import xp, xps
3636
from .stubs import category_to_funcs
3737

38-
pytestmark = pytest.mark.ci
39-
4038
UnaryCheck = Callable[[float], bool]
4139
BinaryCheck = Callable[[float, float], bool]
4240

@@ -1212,6 +1210,7 @@ def parse_binary_case_block(case_block: str) -> List[BinaryCase]:
12121210
assert len(iop_params) != 0
12131211

12141212

1213+
@pytest.mark.unvectorized
12151214
@pytest.mark.parametrize("func_name, func, case", unary_params)
12161215
@given(
12171216
x=hh.arrays(dtype=xps.floating_dtypes(), shape=hh.shapes(min_side=1)),
@@ -1250,6 +1249,7 @@ def test_unary(func_name, func, case, x, data):
12501249
)
12511250

12521251

1252+
@pytest.mark.unvectorized
12531253
@pytest.mark.parametrize("func_name, func, case", binary_params)
12541254
@given(x1=x1_strat, x2=x2_strat, data=st.data())
12551255
def test_binary(func_name, func, case, x1, x2, data):
@@ -1294,6 +1294,7 @@ def test_binary(func_name, func, case, x1, x2, data):
12941294
assume(good_example)
12951295

12961296

1297+
@pytest.mark.unvectorized
12971298
@pytest.mark.parametrize("iop_name, iop, case", iop_params)
12981299
@given(
12991300
oneway_dtypes=hh.oneway_promotable_dtypes(dh.real_float_dtypes),

Diff for: array_api_tests/test_statistical_functions.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
from ._array_module import _UndefinedStub
1616
from .typing import DataType
1717

18-
pytestmark = pytest.mark.ci
19-
2018

2119
def kwarg_dtypes(dtype: DataType) -> st.SearchStrategy[Optional[DataType]]:
2220
dtypes = [d2 for d1, d2 in dh.promotion_table if d1 == dtype]
@@ -25,6 +23,7 @@ def kwarg_dtypes(dtype: DataType) -> st.SearchStrategy[Optional[DataType]]:
2523
return st.none() | st.sampled_from(dtypes)
2624

2725

26+
@pytest.mark.unvectorized
2827
@given(
2928
x=hh.arrays(
3029
dtype=xps.real_dtypes(),
@@ -77,6 +76,7 @@ def test_mean(x, data):
7776
# Values testing mean is too finicky
7877

7978

79+
@pytest.mark.unvectorized
8080
@given(
8181
x=hh.arrays(
8282
dtype=xps.real_dtypes(),
@@ -107,6 +107,7 @@ def test_min(x, data):
107107
ph.assert_scalar_equals("min", type_=scalar_type, idx=out_idx, out=min_, expected=expected)
108108

109109

110+
@pytest.mark.unvectorized
110111
@given(
111112
x=hh.arrays(
112113
dtype=xps.numeric_dtypes(),
@@ -195,6 +196,7 @@ def test_std(x, data):
195196
# We can't easily test the result(s) as standard deviation methods vary a lot
196197

197198

199+
@pytest.mark.unvectorized
198200
@pytest.mark.skip("flaky") # TODO: fix!
199201
@given(
200202
x=hh.arrays(
@@ -247,6 +249,7 @@ def test_sum(x, data):
247249
ph.assert_scalar_equals("sum", type_=scalar_type, idx=out_idx, out=sum_, expected=expected)
248250

249251

252+
@pytest.mark.unvectorized
250253
@pytest.mark.skip(reason="flaky") # TODO: fix!
251254
@given(
252255
x=hh.arrays(

0 commit comments

Comments
 (0)