Skip to content

Commit 1220d6e

Browse files
committed
Merge branch 'master' into more-linalg2
2 parents d41d0bd + d71787e commit 1220d6e

File tree

90 files changed

+2590
-8051
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+2590
-8051
lines changed

.github/workflows/numpy.yml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ jobs:
1111
python-version: [3.8, 3.9]
1212

1313
steps:
14-
- uses: actions/checkout@v1
14+
- name: Checkout array-api-tests
15+
uses: actions/checkout@v1
16+
with:
17+
submodules: 'true'
1518
- name: Set up Python ${{ matrix.python-version }}
1619
uses: actions/setup-python@v1
1720
with:
@@ -30,8 +33,6 @@ jobs:
3033
3134
# copy not implemented
3235
array_api_tests/test_creation_functions.py::test_asarray_arrays
33-
# https://github.com/numpy/numpy/issues/18881
34-
array_api_tests/test_creation_functions.py::test_linspace
3536
# https://github.com/numpy/numpy/issues/20870
3637
array_api_tests/test_data_type_functions.py::test_can_cast
3738
# The return dtype for trace is not consistent in the spec
@@ -44,6 +45,37 @@ jobs:
4445
# https://github.com/numpy/numpy/issues/20326#issuecomment-1012380448
4546
array_api_tests/test_set_functions.py
4647
48+
# https://github.com/numpy/numpy/issues/21373
49+
array_api_tests/test_array_object.py::test_getitem
50+
51+
# missing copy arg
52+
array_api_tests/test_signatures.py::test_func_signature[reshape]
53+
54+
# https://github.com/numpy/numpy/issues/21211
55+
array_api_tests/test_special_cases.py::test_iop[__iadd__(x1_i is -0 and x2_i is -0) -> -0]
56+
# https://github.com/numpy/numpy/issues/21213
57+
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]
58+
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]
59+
# noted diversions from spec
60+
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity]
61+
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is +infinity and isfinite(x2_i) and x2_i < 0) -> -infinity]
62+
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is -infinity and isfinite(x2_i) and x2_i > 0) -> -infinity]
63+
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is -infinity and isfinite(x2_i) and x2_i < 0) -> +infinity]
64+
array_api_tests/test_special_cases.py::test_binary[floor_divide(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> -0]
65+
array_api_tests/test_special_cases.py::test_binary[floor_divide(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> -0]
66+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity]
67+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i < 0) -> -infinity]
68+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i > 0) -> -infinity]
69+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i < 0) -> +infinity]
70+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> -0]
71+
array_api_tests/test_special_cases.py::test_binary[__floordiv__(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> -0]
72+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity]
73+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i < 0) -> -infinity]
74+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i > 0) -> -infinity]
75+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i < 0) -> +infinity]
76+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> -0]
77+
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> -0]
78+
4779
EOF
4880
4981
pytest -v -rxXfE --ci

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,6 @@ dmypy.json
127127

128128
# Pyre type checker
129129
.pyre/
130+
131+
# pytest-json-report
132+
.report.json

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "array_api_tests/array-api"]
2+
path = array-api
3+
url = https://github.com/data-apis/array-api/

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ welcome!
1010

1111
### Setup
1212

13+
Currently we pin the Array API specification repo [`array-api`](https://github.com/data-apis/array-api/)
14+
as a git submodule. This might change in the future to better support vendoring
15+
use cases (see [#107](https://github.com/data-apis/array-api-tests/issues/107)),
16+
but for now be sure submodules are pulled too, e.g.
17+
18+
```bash
19+
$ git submodule update --init
20+
```
21+
1322
To run the tests, install the testing dependencies.
1423

1524
```bash

array-api

Submodule array-api added at c5808f2

array_api_tests/__init__.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
from functools import wraps
22

33
from hypothesis import strategies as st
4-
from hypothesis.extra.array_api import make_strategies_namespace
4+
from hypothesis.extra import array_api
55

66
from ._array_module import mod as _xp
77

88
__all__ = ["xps"]
99

10-
xps = make_strategies_namespace(_xp)
11-
1210

1311
# We monkey patch floats() to always disable subnormals as they are out-of-scope
1412

@@ -23,5 +21,29 @@ def floats(*a, **kw):
2321

2422
st.floats = floats
2523

24+
25+
# We do the same with xps.from_dtype() - this is not strictly necessary, as
26+
# the underlying floats() will never generate subnormals. We only do this
27+
# because internal logic in xps.from_dtype() assumes xp.finfo() has its
28+
# attributes as scalar floats, which is expected behaviour but disrupts many
29+
# unrelated tests.
30+
try:
31+
__from_dtype = array_api._from_dtype
32+
33+
@wraps(__from_dtype)
34+
def _from_dtype(*a, **kw):
35+
kw["allow_subnormal"] = False
36+
return __from_dtype(*a, **kw)
37+
38+
array_api._from_dtype = _from_dtype
39+
except AttributeError:
40+
# Ignore monkey patching if Hypothesis changes the private API
41+
pass
42+
43+
44+
xps = array_api.make_strategies_namespace(_xp)
45+
46+
2647
from . import _version
27-
__version__ = _version.get_versions()['version']
48+
49+
__version__ = _version.get_versions()["version"]

array_api_tests/_array_module.py

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
from importlib import import_module
33

4-
from . import function_stubs
4+
from . import stubs
55

66
# Replace this with a specific array module to test it, for example,
77
#
@@ -53,38 +53,18 @@ def __repr__(self):
5353
__call__ = _raise
5454
__getattr__ = _raise
5555

56-
_integer_dtypes = [
57-
'int8',
58-
'int16',
59-
'int32',
60-
'int64',
61-
'uint8',
62-
'uint16',
63-
'uint32',
64-
'uint64',
65-
]
66-
67-
_floating_dtypes = [
68-
'float32',
69-
'float64',
70-
]
71-
72-
_numeric_dtypes = [
73-
*_integer_dtypes,
74-
*_floating_dtypes,
75-
]
76-
77-
_boolean_dtypes = [
78-
'bool',
79-
]
80-
8156
_dtypes = [
82-
*_boolean_dtypes,
83-
*_numeric_dtypes
57+
"bool",
58+
"uint8", "uint16", "uint32", "uint64",
59+
"int8", "int16", "int32", "int64",
60+
"float32", "float64",
8461
]
62+
_constants = ["e", "inf", "nan", "pi"]
63+
_funcs = [f.__name__ for funcs in stubs.category_to_funcs.values() for f in funcs]
64+
_top_level_attrs = _dtypes + _constants + _funcs + stubs.EXTENSIONS
8565

86-
for func_name in function_stubs.__all__ + _dtypes:
66+
for attr in _top_level_attrs:
8767
try:
88-
globals()[func_name] = getattr(mod, func_name)
68+
globals()[attr] = getattr(mod, attr)
8969
except AttributeError:
90-
globals()[func_name] = _UndefinedStub(func_name)
70+
globals()[attr] = _UndefinedStub(attr)

array_api_tests/conftest.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import re
2+
3+
import pytest
4+
5+
r_int_pow_promotion = re.compile(r"test.+promotion\[.*pow.*\(u?int.+\]")
6+
7+
8+
def pytest_collection_modifyitems(config, items):
9+
"""Skips the faulty integer type promotion tests for pow-related functions"""
10+
for item in items:
11+
if r_int_pow_promotion.match(item.name):
12+
item.add_marker(
13+
pytest.mark.skip(
14+
reason="faulty test logic - negative exponents generated"
15+
)
16+
)

0 commit comments

Comments
 (0)