hypothesis
hypothesis copied to clipboard
Extend `extra.array_api` docs to demonstrate how one could generate top-level array/tensor objects
In the relevant docs page, we currently exclaim:
If you want to test with CuPy, Dask, JAX, MXNet, PyTorch, TensorFlow, or Xarray, this is the extension for you!
This is true (or at least will be when the respective libraries adopt Array API), but it would be nice to demonstrate how this could work in practice. There seems to be two scenarios that need to be covered:
- Adopting libraries which expose a submodule as the Array API namespace e.g.
numpy.array_api
- Adopting libraries make their top-level module compliant with the Array API e.g. PyTorch in pytorch/pytorch#58743
For our first case, I was talking with @rgommers and he expects these libraries will offer a way to interop the Array API array object with the libraries "top-level" array/tensor object. For example, NumPy currently just wraps its ndarray
, so in the future it should either expose the underling ndarray
publicly in the Array API array object, or provide some method to convert its Array API array into a ndarray
proper. I think it'd be good to provide short recipes for all of these libraries.
For our second case, assuming all these libraries are also making their top-level array/tensor compliant with the Array API, we can just note that for the relevant libraries xps.arrays()
is enough.
If folk agree we should do this... there's not much we can do right now anywho. I thought I'd raise the issue so we don't forget!