Skip to content

Commit

Permalink
Merge pull request #3901 from honno/array-api-2023
Browse files Browse the repository at this point in the history
Support `2023.12` version of the array API
  • Loading branch information
Zac-HD committed Feb 29, 2024
2 parents 9457197 + 1bdd5fc commit 164c4f0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
8 changes: 8 additions & 0 deletions hypothesis-python/RELEASE.rst
@@ -0,0 +1,8 @@
RELEASE_TYPE: patch

This release adds support for the Array API's `2023.12 release
<https://data-apis.org/array-api/2023.12/>`_ via the ``api_version`` argument in
:func:`~hypothesis.extra.array_api.make_strategies_namespace`. The API additions
and modifications in the ``2023.12`` spec do not necessitate any changes in the
Hypothesis strategies, hence there is no distinction between a ``2022.12`` and
``2023.12`` strategies namespace.
2 changes: 1 addition & 1 deletion hypothesis-python/docs/numpy.rst
Expand Up @@ -63,7 +63,7 @@ Hypothesis offers strategies for `Array API <https://data-apis.org/>`_ adopting
libraries in the ``hypothesis.extra.array_api`` package. See :issue:`3037` for
more details. If you want to test with :pypi:`CuPy`, :pypi:`Dask`, :pypi:`JAX`,
:pypi:`MXNet`, :pypi:`PyTorch <torch>`, :pypi:`TensorFlow`, or :pypi:`Xarray` -
or just ``numpy.array_api`` - this is the extension for you!
or just :pypi:`NumPy` - this is the extension for you!

.. autofunction:: hypothesis.extra.array_api.make_strategies_namespace

Expand Down
4 changes: 2 additions & 2 deletions hypothesis-python/src/hypothesis/extra/array_api.py
Expand Up @@ -69,10 +69,10 @@
]


RELEASED_VERSIONS = ("2021.12", "2022.12")
RELEASED_VERSIONS = ("2021.12", "2022.12", "2023.12")
NOMINAL_VERSIONS = (*RELEASED_VERSIONS, "draft")
assert sorted(NOMINAL_VERSIONS) == list(NOMINAL_VERSIONS) # sanity check
NominalVersion = Literal["2021.12", "2022.12", "draft"]
NominalVersion = Literal["2021.12", "2022.12", "2023.12", "draft"]
assert get_args(NominalVersion) == NOMINAL_VERSIONS # sanity check


Expand Down
7 changes: 5 additions & 2 deletions hypothesis-python/tests/array_api/README.md
Expand Up @@ -3,7 +3,7 @@ This folder contains tests for `hypothesis.extra.array_api`.
## Mocked array module

A mock of the Array API namespace exists as `mock_xp` in `extra.array_api`. This
wraps NumPy-proper to conform it to the *draft* spec, where `numpy.array_api`
wraps NumPy-proper to conform it to the *draft* spec, where `array_api_strict`
might not. This is not a fully compliant wrapper, but conforms enough for the
purposes of testing.

Expand All @@ -21,7 +21,7 @@ If neither of these, the test suite will then try resolve the variable like so:
1. If the variable matches a name of an available entry point, load said entry point.
2. If the variables matches a valid import path, import said path.

For example, to specify NumPy's Array API implementation, you could use its
For example, to specify NumPy's Array API implementation[^1], you could use its
entry point (**1.**),

HYPOTHESIS_TEST_ARRAY_API=numpy pytest tests/array_api
Expand All @@ -48,3 +48,6 @@ Otherwise the test suite will use the variable as the `api_version` argument for
In the future we intend to support running tests against multiple API versioned
namespaces, likely with an additional recognized option that infers all
supported versions.

[^1]: Note NumPy will likely remove `numpy.array_api` in the future ([NEP 56](https://github.com/numpy/numpy/pull/25542))
in favour of the third-party [`array-api-strict`](https://github.com/data-apis/array-api-strict) library.

0 comments on commit 164c4f0

Please sign in to comment.