Skip to content

Utilise RST conversion of spec, generate runtime special cases tests #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 63 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
61eec43
Add `array-api` spec as submodule, load its signatures
honno Feb 8, 2022
6a4fffc
Rudimentary special case tests on runtime
honno Feb 9, 2022
ee68b89
Rudimentary testing for binary elwise special cases
honno Feb 10, 2022
1ef5b3e
Use `ph` for pos/neg zero utils
honno Feb 11, 2022
14c4793
More binary cases coverage
honno Feb 11, 2022
a937d26
Cover most sign special cases
honno Feb 14, 2022
08aebde
Rudimentary rework of value condition factories
honno Feb 15, 2022
e6f1064
Factories for result check functions
honno Feb 15, 2022
74cc8e5
Skip redundant special cases
honno Feb 15, 2022
03b9c00
Generalise not special cases
honno Feb 15, 2022
0058634
Parse either cases
honno Feb 15, 2022
0116ac5
Parse sign cases
honno Feb 15, 2022
bc85e7a
Parse more awkward equality special cases
honno Feb 16, 2022
1891a79
Parse abs special cases
honno Feb 16, 2022
d7db62d
Cond reprs, merge abs cond logic, fix approx cond factories
honno Feb 16, 2022
b0ed32f
Mark special case tests for CI
honno Feb 17, 2022
05e179e
`repr_` -> `expr`, return `BinaryCond` in `SignCondFactory`
honno Feb 17, 2022
d6f4f56
Fix abs conds not actually absifying
honno Feb 17, 2022
3d0478f
Reorder binary case patterns to avoid false matches
honno Feb 17, 2022
0ba6753
Parse quad cases
honno Feb 17, 2022
404542f
Parse most unary cases again, refactor parse utils
honno Feb 18, 2022
4ea0154
Parse even round case
honno Feb 18, 2022
e808673
Factor out class bloat for unary params
honno Feb 18, 2022
a90760c
Rudimentary generic condition parsing for binary cases
honno Feb 21, 2022
f915993
Bring back full case coverage
honno Feb 21, 2022
a1a5780
Fix local func definitions causing pass-by-reference problems
honno Mar 1, 2022
03b8f32
Use spec reprs for case `expr`
honno Mar 1, 2022
ef10e90
Factor out logic for input eq conds/results
honno Mar 2, 2022
e9e99ab
Enable submodules for NumPy workflow
honno Mar 2, 2022
709cb4c
Rudimentary cond element strategy pattern to ensure good examples
honno Mar 3, 2022
9c7c051
Cond strategies for most binary cases
honno Mar 9, 2022
420a549
Cover binary cases with two unary conds for one array
honno Mar 10, 2022
e6f9548
Cover "equal to" cases (as opposed to "is" cases)
honno Mar 10, 2022
c5a30d0
Test xor scenarios for either special cases
honno Mar 11, 2022
2217bb9
Comment on `__future__` and either case strategies
honno Mar 11, 2022
4372e90
Update NumPy workflow for new special cases
honno Mar 11, 2022
6c775a7
Generate x1 is x2 conds (and visa versa) healthily
honno Mar 14, 2022
6d8c3ca
Favour `ParseError` to assertions
honno Mar 14, 2022
63d63e1
Note check_result def problems
honno Mar 14, 2022
171ee5a
Document `BoundFromDtype` with extensive examples
honno Mar 14, 2022
cb810b9
Document `parse_cond`
honno Mar 14, 2022
ddb287a
Document `parse_result()`
honno Mar 14, 2022
67891b8
Factor out `UnaryCase.from_strings()`
honno Mar 14, 2022
b600230
Better exception messages
honno Mar 14, 2022
a9a5234
Not worry about removing spec package from path
honno Mar 14, 2022
180b152
Doc fixes
honno Mar 15, 2022
6c802c3
Document `parse_unary_docstring()`
honno Mar 15, 2022
eaa3b05
Document `parse_binary_docstring()`
honno Mar 15, 2022
8b24204
Extend `good_examples` comment
honno Mar 15, 2022
5a9ea21
Move `array-api` submodule to the top-level
honno Mar 15, 2022
795fd04
Minor doc fixes
honno Mar 15, 2022
f0c3df4
Document `make_binary_cond()`
honno Mar 16, 2022
546827e
Document `make_eq_input_check_result()`
honno Mar 16, 2022
f5b0975
Make `parse_cond()` only return `BoundFromDtype`
honno Mar 16, 2022
3773a4d
Document `parse_binary_case()`
honno Mar 16, 2022
f82fee5
Generate and test the even rounding halves case correctly
honno Mar 16, 2022
558ffdc
Case expression fixes
honno Mar 16, 2022
456fc6c
Drop outdated `x<1/2>_cond_from_dtype` logic
honno Mar 17, 2022
d95c2ab
Test special cases for operators
honno Mar 17, 2022
9eac45b
Update skipped NumPy workflow tests
honno Mar 17, 2022
2068ee4
Better repr for failing `ipow` special case test
honno Mar 17, 2022
27a00d7
Update workflow with another failing `__ipow__()` case
honno Mar 18, 2022
6642522
Note submodule in readme
honno Mar 22, 2022
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
29 changes: 28 additions & 1 deletion .github/workflows/numpy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ jobs:
python-version: [3.8, 3.9]

steps:
- uses: actions/checkout@v1
- name: Checkout array-api-tests
uses: actions/checkout@v1
with:
submodules: 'true'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
Expand Down Expand Up @@ -40,6 +43,30 @@ jobs:
# waiting on NumPy to allow/revert distinct NaNs for np.unique
# https://github.com/numpy/numpy/issues/20326#issuecomment-1012380448
array_api_tests/test_set_functions.py
# https://github.com/numpy/numpy/issues/21211
array_api_tests/test_special_cases.py::test_iop[__iadd__(x1_i is -0 and x2_i is -0) -> -0]
# https://github.com/numpy/numpy/issues/21213
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]
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]
# noted diversions from spec
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity]
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is +infinity and isfinite(x2_i) and x2_i < 0) -> -infinity]
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is -infinity and isfinite(x2_i) and x2_i > 0) -> -infinity]
array_api_tests/test_special_cases.py::test_binary[floor_divide(x1_i is -infinity and isfinite(x2_i) and x2_i < 0) -> +infinity]
array_api_tests/test_special_cases.py::test_binary[floor_divide(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> -0]
array_api_tests/test_special_cases.py::test_binary[floor_divide(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> -0]
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity]
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i < 0) -> -infinity]
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i > 0) -> -infinity]
array_api_tests/test_special_cases.py::test_binary[__floordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i < 0) -> +infinity]
array_api_tests/test_special_cases.py::test_binary[__floordiv__(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> -0]
array_api_tests/test_special_cases.py::test_binary[__floordiv__(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> -0]
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i > 0) -> +infinity]
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is +infinity and isfinite(x2_i) and x2_i < 0) -> -infinity]
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i > 0) -> -infinity]
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(x1_i is -infinity and isfinite(x2_i) and x2_i < 0) -> +infinity]
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(isfinite(x1_i) and x1_i > 0 and x2_i is -infinity) -> -0]
array_api_tests/test_special_cases.py::test_iop[__ifloordiv__(isfinite(x1_i) and x1_i < 0 and x2_i is +infinity) -> -0]

EOF

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "array_api_tests/array-api"]
path = array-api
url = https://github.com/data-apis/array-api/
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ welcome!

### Setup

Currently we pin the Array API specification repo [`array-api`](https://github.com/data-apis/array-api/)
as a git submodule. This might change in the future to better support vendoring
use cases (see [#107](https://github.com/data-apis/array-api-tests/issues/107)),
but for now be sure submodules are pulled too, e.g.

```bash
$ git submodule update --init
```

To run the tests, install the testing dependencies.

```bash
Expand Down
1 change: 1 addition & 0 deletions array-api
Submodule array-api added at 2b9c40
10 changes: 10 additions & 0 deletions array_api_tests/meta/test_special_cases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import math

from ..test_special_cases import parse_result


def test_parse_result():
check_result, _ = parse_result(
"an implementation-dependent approximation to ``+3π/4``"
)
assert check_result(3 * math.pi / 4)
Empty file.
53 changes: 0 additions & 53 deletions array_api_tests/special_cases/test_abs.py

This file was deleted.

66 changes: 0 additions & 66 deletions array_api_tests/special_cases/test_acos.py

This file was deleted.

66 changes: 0 additions & 66 deletions array_api_tests/special_cases/test_acosh.py

This file was deleted.

Loading