Skip to content

Commit 1ae5ea7

Browse files
authored
Merge pull request #93 from honno/readme
Minor `README.md` improvements
2 parents b7ab914 + d7b184c commit 1ae5ea7

File tree

2 files changed

+139
-55
lines changed

2 files changed

+139
-55
lines changed

.github/workflows/numpy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
env:
2626
ARRAY_API_TESTS_MODULE: numpy.array_api
2727
run: |
28-
# Skip test cases with known issues
28+
# Skip testing functions with known issues
2929
cat << EOF >> skips.txt
3030
3131
# copy not implemented
@@ -35,7 +35,7 @@ jobs:
3535
# https://github.com/numpy/numpy/issues/20870
3636
array_api_tests/test_data_type_functions.py::test_can_cast
3737
# The return dtype for trace is not consistent in the spec
38-
# (https://github.com/data-apis/array-api/issues/202#issuecomment-952529197)
38+
# https://github.com/data-apis/array-api/issues/202#issuecomment-952529197
3939
array_api_tests/test_linalg.py::test_trace
4040
# waiting on NumPy to allow/revert distinct NaNs for np.unique
4141
# https://github.com/numpy/numpy/issues/20326#issuecomment-1012380448

README.md

Lines changed: 137 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -50,47 +50,6 @@ a specific test case, which is useful when developing functions.
5050
$ pytest array_api_tests/test_creation_functions.py::test_zeros
5151
```
5252

53-
## Releases
54-
55-
The test suite has tagged releases on
56-
[GitHub](https://github.com/data-apis/array-api-tests/releases). If you run
57-
the test suite in your CI system, we recommend pinning against a release tag.
58-
59-
We use [calender versioning](https://calver.org/) for the releases. You should
60-
expect that any version may be "breaking" compared to the previous one, in the
61-
sense that there may have been additional tests added which cause a previously
62-
passing library to fail.
63-
64-
For now, the test suite is
65-
not installable as a Python package. You can use it by cloning the repo and
66-
running `pytest` as described above. If it would help you to be able to
67-
install it as a package, [please let us
68-
know](https://github.com/data-apis/array-api-tests/issues/85).
69-
70-
*Test suite maintainer note:* to make a release of the test suite, make an
71-
annotated tag with the version:
72-
73-
```
74-
git tag -a 2022.1
75-
```
76-
77-
(for the message, just write something like "array-api-tests version 2022.1").
78-
Be sure to use the calver version number for the tag name. Versioneer will
79-
automatically set the version number of the `array_api_tests` package based on
80-
the git tag.
81-
82-
Then push the tag to GitHub
83-
84-
```
85-
git push --tags origin 2022.1
86-
```
87-
88-
Finally go to the [tags page on
89-
GitHub](https://github.com/data-apis/array-api-tests/tags) and convert the tag
90-
into a release. If you want, you can add release notes to the release page on
91-
GitHub.
92-
93-
9453
## What the test suite covers
9554

9655
We are interested in array libraries conforming to the
@@ -101,12 +60,13 @@ so as to not unexpectedly fail the suite.
10160

10261
### Primary tests
10362

104-
Every function—including array object methods—has a respective test method. We
105-
use [Hypothesis](https://hypothesis.readthedocs.io/en/latest/) to generate a
106-
diverse set of valid inputs. This means array inputs will cover different dtypes
107-
and shapes, as well as contain interesting elements. These examples generate
108-
with interesting arrangements of non-array positional arguments and keyword
109-
arguments.
63+
Every function—including array object methods—has a respective test
64+
method<sup>1</sup>. We use
65+
[Hypothesis](https://hypothesis.readthedocs.io/en/latest/)
66+
to generate a diverse set of valid inputs. This means array inputs will cover
67+
different dtypes and shapes, as well as contain interesting elements. These
68+
examples generate with interesting arrangements of non-array positional
69+
arguments and keyword arguments.
11070

11171
Each test case will cover the following areas if relevant:
11272

@@ -147,7 +107,7 @@ of the functions and some miscellaneous things.
147107
functions interact with them correctly.
148108

149109
Be aware that some aspects of the spec are impractical or impossible to actually
150-
test, so they are not covered in the suite <!-- TODO: note what these are -->
110+
test, so they are not covered in the suite. <!-- TODO: note what these are -->
151111

152112
## Interpreting errors
153113

@@ -172,21 +132,100 @@ behaviour different from the spec, or test something that is not documented,
172132
this is a bug—please [report such
173133
issues](https://github.com/data-apis/array-api-tests/issues/) to us.
174134

175-
## Configuration
135+
136+
## Running on CI
137+
138+
See our existing [GitHub Actions workflow for
139+
Numpy](https://github.com/data-apis/array-api-tests/blob/master/.github/workflows/numpy.yml)
140+
for an example of using the test suite on CI.
141+
142+
### Releases
143+
144+
We recommend pinning against a [release tag](https://github.com/data-apis/array-api-tests/releases)
145+
when running on CI.
146+
147+
We use [calender versioning](https://calver.org/) for the releases. You should
148+
expect that any version may be "breaking" compared to the previous one, in that
149+
new tests (or improvements to existing tests) may cause a previously passing
150+
library to fail.
151+
152+
### Configuration
153+
154+
#### CI flag
155+
156+
Use the `--ci` flag to run only the primary and special cases tests. You can
157+
ignore the other test cases as they are redundant for the purposes of checking
158+
compliance.
159+
160+
#### Extensions
176161

177162
By default, tests for the optional Array API extensions such as
178163
[`linalg`](https://data-apis.org/array-api/latest/extensions/linear_algebra_functions.html)
179164
will be skipped if not present in the specified array module. You can purposely
180165
skip testing extension(s) via the `--disable-extension` option.
181166

167+
#### Skip test cases
168+
169+
Test cases you want to skip can be specified in a `skips.txt` file in the root
170+
of this repository, e.g.:
171+
172+
```
173+
# ./skips.txt
174+
# Line comments can be denoted with the hash symbol (#)
175+
176+
# Skip specific test case, e.g. when argsort() does not respect relative order
177+
# https://github.com/numpy/numpy/issues/20778
178+
array_api_tests/test_sorting_functions.py::test_argsort
179+
180+
# Skip specific test case parameter, e.g. you forgot to implement in-place adds
181+
array_api_tests/test_add[__iadd__(x1, x2)]
182+
array_api_tests/test_add[__iadd__(x, s)]
183+
184+
# Skip module, e.g. when your set functions treat NaNs as non-distinct
185+
# https://github.com/numpy/numpy/issues/20326
186+
array_api_tests/test_set_functions.py
187+
```
188+
189+
For GitHub Actions, you might like to keep everything in the workflow config
190+
instead of having a seperate `skips.txt` file, e.g.:
191+
192+
```yaml
193+
# ./.github/workflows/array_api.yml
194+
...
195+
...
196+
- name: Run the test suite
197+
env:
198+
ARRAY_API_TESTS_MODULE: your.array.api.namespace
199+
run: |
200+
# Skip test cases with known issues
201+
cat << EOF >> skips.txt
202+
203+
# Skip specific test case, e.g. when argsort() does not respect relative order
204+
# https://github.com/numpy/numpy/issues/20778
205+
array_api_tests/test_sorting_functions.py::test_argsort
206+
207+
# Skip specific test case parameter, e.g. you forgot to implement in-place adds
208+
array_api_tests/test_add[__iadd__(x1, x2)]
209+
array_api_tests/test_add[__iadd__(x, s)]
210+
211+
# Skip module, e.g. when your set functions treat NaNs as non-distinct
212+
# https://github.com/numpy/numpy/issues/20326
213+
array_api_tests/test_set_functions.py
214+
215+
EOF
216+
217+
pytest -v -rxXfE --ci
218+
```
219+
220+
#### Max examples
221+
182222
The tests make heavy use
183223
[Hypothesis](https://hypothesis.readthedocs.io/en/latest/). You can configure
184224
how many examples are generated using the `--max-examples` flag, which defaults
185225
to 100. Lower values can be useful for quick checks, and larger values should
186-
result in more rigorous runs. For example, `--max-examples 10000` may find bugs
187-
where default runs don't, but will take a much longer time.
226+
result in more rigorous runs. For example, `--max-examples 10_000` may find bugs
227+
where default runs don't but will take much longer to run.
188228

189-
<!-- TODO: howto on CI -->
190229

191230
## Contributing
192231

@@ -200,7 +239,7 @@ many utilities that parralel NumPy's own test utils in the `*_helpers.py` files.
200239

201240
### Tools
202241

203-
Hypothesis should always be used for the primary tests, and can be useful
242+
Hypothesis should almost always be used for the primary tests, and can be useful
204243
elsewhere. Effort should be made so drawn arguments are labeled with their
205244
respective names. For
206245
[`st.data()`](https://hypothesis.readthedocs.io/en/latest/data.html#hypothesis.strategies.data),
@@ -231,6 +270,31 @@ where `path/to/array-api` is the path to a local clone of the [`array-api`
231270
repo](https://github.com/data-apis/array-api/). Edit `generate_stubs.py` to make
232271
changes to the generated files.
233272

273+
274+
### Release
275+
276+
To make a release, first make an annotated tag with the version, e.g.:
277+
278+
```
279+
git tag -a 2022.01.01
280+
```
281+
282+
Be sure to use the calver version number for the tag name. Don't worry too much
283+
on the tag message, e.g. just write "2022.01.01".
284+
285+
Versioneer will automatically set the version number of the `array_api_tests`
286+
package based on the git tag. Push the tag to GitHub:
287+
288+
```
289+
git push --tags upstream 2022.1
290+
```
291+
292+
Then go to the [tags page on
293+
GitHub](https://github.com/data-apis/array-api-tests/tags) and convert the tag
294+
into a release. If you want, you can add release notes, which GitHub can
295+
generate for you.
296+
297+
234298
## Future plans
235299

236300
Keeping full coverage of the spec is an on-going priority as the Array API
@@ -250,3 +314,23 @@ come across.
250314
for output values (particularly epsilons for floating-point outputs), so we
251315
need to review these and either implement assertions or properly note the lack
252316
thereof.
317+
318+
---
319+
320+
<sup>1</sup>The only exceptions to having just one primary test per function are:
321+
322+
* [`asarray()`](https://data-apis.org/array-api/latest/API_specification/generated/signatures.creation_functions.asarray.html),
323+
which is tested by `test_asarray_scalars` and `test_asarray_arrays` in
324+
`test_creation_functions.py`. Testing `asarray()` works with scalars (and
325+
nested sequences of scalars) is fundamental to testing that it works with
326+
arrays, as said arrays can only be generated by passing scalar sequences to
327+
`asarray()`.
328+
329+
* Indexing methods
330+
([`__getitem__()`](https://data-apis.org/array-api/latest/API_specification/generated/signatures.array_object.array.__getitem__.html)
331+
and
332+
[`__setitem__()`](https://data-apis.org/array-api/latest/API_specification/generated/signatures.array_object.array.__setitem__.html)),
333+
which respectively have both a test for non-array indices and a test for
334+
boolean array indices. This is because [masking is
335+
opt-in](https://data-apis.org/array-api/latest/API_specification/indexing.html#boolean-array-indexing)
336+
(and boolean arrays need to be generated by indexing arrays anyway).

0 commit comments

Comments
 (0)