Skip to content

Commit 420fdf8

Browse files
authored
Merge pull request #3065 from honno/honno/array-api
2 parents 1393ae5 + 500fd15 commit 420fdf8

18 files changed

Lines changed: 2253 additions & 8 deletions

‎AUTHORS.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ their individual contributions.
88

99
.. NOTE - this list is in alphabetical order by first name (or handle).
1010
11+
* `Aaron Meurer <https://github.com/asmeurer>`_
1112
* `Adam Johnson <https://github.com/adamchainz>`_
1213
* `Adam Sven Johnson <https://www.github.com/pkqk>`_
1314
* `Afrida Tabassum <https://github.com/oxfordhalfblood>`_ ([email protected])
@@ -93,6 +94,7 @@ their individual contributions.
9394
* `Markus Unterwaditzer <https://github.com/untitaker>`_ ([email protected])
9495
* `Mathieu Paturel <https://github.com/math2001>`_ ([email protected])
9596
* `Matt Bachmann <https://www.github.com/bachmann1234>`_ ([email protected])
97+
* `Matthew Barber <https://www.github.com/honno>`_ ([email protected])
9698
* `Max Nordlund <https://www.github.com/maxnordlund>`_ ([email protected])
9799
* `Maxim Kulkin <https://www.github.com/maximkulkin>`_ ([email protected])
98100
* `Michel Alexandre Salim <https://github.com/michel-slm>`_ ([email protected])

‎hypothesis-python/RELEASE.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
RELEASE_TYPE: minor
2+
3+
This release introduces strategies for array/tensor libraries adopting the
4+
`Array API standard <https://data-apis.org/>`__ (:issue:`3037`).
5+
They are available in :ref:`the hypothesis.extra.array_api extra <array-api>`,
6+
and work much like the existing :doc:`strategies for NumPy <numpy>`.

‎hypothesis-python/docs/conf.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import datetime
1717
import os
1818
import sys
19+
import types
1920

2021
import sphinx_rtd_theme
2122

@@ -59,6 +60,14 @@ def setup(app):
5960
if os.path.isfile(os.path.join(os.path.dirname(__file__), "..", "RELEASE.rst")):
6061
app.tags.add("has_release_file")
6162

63+
# patch in mock array_api namespace so we can autodoc it
64+
from hypothesis.extra.array_api import make_strategies_namespace, mock_xp
65+
66+
mod = types.ModuleType("xps")
67+
mod.__dict__.update(make_strategies_namespace(mock_xp).__dict__)
68+
assert "xps" not in sys.modules
69+
sys.modules["xps"] = mod
70+
6271

6372
language = None
6473

@@ -98,6 +107,7 @@ def setup(app):
98107
"pypi": ("https://pypi.org/project/%s/", ""),
99108
"bpo": ("https://bugs.python.org/issue%s", "bpo-"),
100109
"np-ref": ("https://numpy.org/doc/stable/reference/%s", ""),
110+
"xp-ref": ("https://data-apis.org/array-api/latest/API_specification/%s", ""),
101111
"wikipedia": ("https://en.wikipedia.org/wiki/%s", ""),
102112
}
103113

‎hypothesis-python/docs/numpy.rst‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,41 @@ and confirmed working with every Pandas minor version from 0.25 through to 1.1.
5252
Releases that are not the latest patch release of their minor version are not
5353
tested or officially supported, but will probably also work unless you hit a
5454
pandas bug.
55+
56+
.. _array-api:
57+
58+
---------
59+
Array API
60+
---------
61+
62+
.. tip::
63+
The Array API standard is not yet finalised, so this module will make breaking
64+
changes if necessary to support newer versions of the standard.
65+
66+
Hypothesis offers strategies for `Array API <https://data-apis.org/>`_ adopting
67+
libraries in the ``hypothesis.extra.array_api`` package. See :issue:`3037` for
68+
more details. If you want to test with :pypi:`CuPy`, :pypi:`Dask`, :pypi:`JAX`,
69+
:pypi:`MXNet`, :pypi:`PyTorch <torch>`, :pypi:`TensorFlow`, or :pypi:`Xarray` -
70+
or just ``numpy.array_api`` - this is the extension for you!
71+
72+
.. autofunction:: hypothesis.extra.array_api.make_strategies_namespace
73+
74+
The resulting namespace contains all our familiar strategies like
75+
:func:`~xps.arrays` and :func:`~xps.from_dtype`, but based on the array-API
76+
standard semantics and returning objects from the ``xp`` module:
77+
78+
.. automodule:: xps
79+
:members:
80+
from_dtype,
81+
arrays,
82+
array_shapes,
83+
scalar_dtypes,
84+
boolean_dtypes,
85+
numeric_dtypes,
86+
integer_dtypes,
87+
unsigned_integer_dtypes,
88+
floating_dtypes,
89+
valid_tuple_axes,
90+
broadcastable_shapes,
91+
mutually_broadcastable_shapes,
92+
indices,

0 commit comments

Comments
 (0)