Skip to content

Commit

Permalink
Merge pull request #3456 from honno/version-xp-namespaces
Browse files Browse the repository at this point in the history
`extra.array_api` versioning + complex support
  • Loading branch information
Zac-HD committed Sep 29, 2022
2 parents 3fc084f + 0e5155d commit e242573
Show file tree
Hide file tree
Showing 15 changed files with 628 additions and 111 deletions.
13 changes: 13 additions & 0 deletions hypothesis-python/RELEASE.rst
@@ -0,0 +1,13 @@
RELEASE_TYPE: minor

In preparation for `future versions of the Array API standard
<https://data-apis.org/array-api/latest/future_API_evolution.html>`__,
:func:`~hypothesis.extra.array_api.make_strategies_namespace` now accepts an
optional ``api_version`` argument, which determines the version conformed to by
the returned strategies namespace. If ``None``, the version of the passed array
module ``xp`` is inferred.

This release also introduces :func:`xps.real_dtypes`. This is currently
equivalent to the existing :func:`xps.numeric_dtypes` strategy, but exists
because the latter is expected to include complex numbers in the next version of
the standard.
10 changes: 8 additions & 2 deletions hypothesis-python/docs/conf.py
Expand Up @@ -57,10 +57,16 @@ def setup(app):
app.tags.add("has_release_file")

# patch in mock array_api namespace so we can autodoc it
from hypothesis.extra.array_api import make_strategies_namespace, mock_xp
from hypothesis.extra.array_api import (
RELEASED_VERSIONS,
make_strategies_namespace,
mock_xp,
)

mod = types.ModuleType("xps")
mod.__dict__.update(make_strategies_namespace(mock_xp).__dict__)
mod.__dict__.update(
make_strategies_namespace(mock_xp, api_version=RELEASED_VERSIONS[-1]).__dict__
)
assert "xps" not in sys.modules
sys.modules["xps"] = mod

Expand Down
4 changes: 4 additions & 0 deletions hypothesis-python/docs/numpy.rst
Expand Up @@ -75,6 +75,9 @@ The resulting namespace contains all our familiar strategies like
:func:`~xps.arrays` and :func:`~xps.from_dtype`, but based on the Array API
standard semantics and returning objects from the ``xp`` module:

..
TODO: for next released xp version, include complex_dtypes here
.. automodule:: xps
:members:
from_dtype,
Expand All @@ -83,6 +86,7 @@ standard semantics and returning objects from the ``xp`` module:
scalar_dtypes,
boolean_dtypes,
numeric_dtypes,
real_dtypes,
integer_dtypes,
unsigned_integer_dtypes,
floating_dtypes,
Expand Down

0 comments on commit e242573

Please sign in to comment.