From 4dc3de89b2d9b5b0b124899597abf7f141e6b0e4 Mon Sep 17 00:00:00 2001 From: Matthew Barber Date: Wed, 28 Feb 2024 09:47:29 +0000 Subject: [PATCH 1/4] Add support for `2023.12` in `extra.array_api` No API changes --- hypothesis-python/src/hypothesis/extra/array_api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hypothesis-python/src/hypothesis/extra/array_api.py b/hypothesis-python/src/hypothesis/extra/array_api.py index d62418f317..e9ff8b3c9e 100644 --- a/hypothesis-python/src/hypothesis/extra/array_api.py +++ b/hypothesis-python/src/hypothesis/extra/array_api.py @@ -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 From 79be20555de4a70bb5bb32779ff781c68226a970 Mon Sep 17 00:00:00 2001 From: Matthew Barber Date: Wed, 28 Feb 2024 09:18:13 +0000 Subject: [PATCH 2/4] Remove/clarify references to `numpy.array_api` Superseded by third-party array-api-strict library --- hypothesis-python/docs/numpy.rst | 2 +- hypothesis-python/tests/array_api/README.md | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hypothesis-python/docs/numpy.rst b/hypothesis-python/docs/numpy.rst index 1ac6d33fdb..be1c9c7b4c 100644 --- a/hypothesis-python/docs/numpy.rst +++ b/hypothesis-python/docs/numpy.rst @@ -63,7 +63,7 @@ Hypothesis offers strategies for `Array API `_ 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 `, :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 diff --git a/hypothesis-python/tests/array_api/README.md b/hypothesis-python/tests/array_api/README.md index bc2f4d1aa2..f841269d7f 100644 --- a/hypothesis-python/tests/array_api/README.md +++ b/hypothesis-python/tests/array_api/README.md @@ -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. @@ -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 @@ -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. \ No newline at end of file From 37d2e1d3d67c20cc90f70ef158e1db5daa1390c1 Mon Sep 17 00:00:00 2001 From: Matthew Barber Date: Wed, 28 Feb 2024 11:04:23 +0000 Subject: [PATCH 3/4] Add `RELEASE.rst` --- hypothesis-python/RELEASE.rst | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 hypothesis-python/RELEASE.rst diff --git a/hypothesis-python/RELEASE.rst b/hypothesis-python/RELEASE.rst new file mode 100644 index 0000000000..bb55d25f5c --- /dev/null +++ b/hypothesis-python/RELEASE.rst @@ -0,0 +1,6 @@ +RELEASE_TYPE: patch + +This release adds support for the Array API's `2023.12 release +`_ via the ``api_version`` argument in +:func:`~hypothesis.extra.array_api.make_strategies_namespace`. There is no +distinction between a ``2012.12`` and ``2023.12`` strategies namespace. \ No newline at end of file From 1bdd5fc1856911e8ad680ddbebe96665528978fd Mon Sep 17 00:00:00 2001 From: Matthew Barber Date: Thu, 29 Feb 2024 10:34:52 +0000 Subject: [PATCH 4/4] Address review comments * Clarify release notes * Link to NEP directly --- hypothesis-python/RELEASE.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hypothesis-python/RELEASE.rst b/hypothesis-python/RELEASE.rst index bb55d25f5c..72be30bd5a 100644 --- a/hypothesis-python/RELEASE.rst +++ b/hypothesis-python/RELEASE.rst @@ -2,5 +2,7 @@ RELEASE_TYPE: patch This release adds support for the Array API's `2023.12 release `_ via the ``api_version`` argument in -:func:`~hypothesis.extra.array_api.make_strategies_namespace`. There is no -distinction between a ``2012.12`` and ``2023.12`` strategies namespace. \ No newline at end of file +: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. \ No newline at end of file