Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support 2023.12 version of the array API #3901

Merged
merged 4 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
honno marked this conversation as resolved.
Show resolved Hide resolved
: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))
honno marked this conversation as resolved.
Show resolved Hide resolved
in favour of the third-party [`array-api-strict`](https://github.com/data-apis/array-api-strict) library.