honno / hypothesis-array-api

Library-agnostic strategies for Array API adopters—now merged into Hypothesis!

Home Page:https://hypothesis.readthedocs.io/en/latest/numpy.html#array-api

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

These strategies now have first-party support in hypothesis.extra.array_api, so please don't use this package!


Hypothesis strategies for Array API libraries

Note: hypothesis-array-api uses private APIs from Hypothesis and so should be considered unstable.

Install

You can get the strategies from PyPI.

pip install hypothesis-array-api

To install from source, get Poetry and then poetry install inside the repository. Using poetry shell is a good idea for development, where you can use pytest to run the full test suite.

Quickstart

from numpy import array_api as xp

from hypothesis import given
from hypothesis_array import get_strategies_namespace

xps = get_strategies_namespace(xp)

@given(xps.arrays(dtype=xps.scalar_strategies(), shape=xps.array_shapes()))
def your_test(array):
    ...

Contributors

@honno created these strategies with input from @mattip, @asmeurer, @rgommers and other great folk from @Quansight-Labs.

Inspiration was taken from the NumPy strategies that Hypothesis ships with at hypothesis.extra.numpy. Thanks to the Hypothesis contributors who helped shape it, including: @Zac-HD, @rsokl, @DRMacIver, @takluyver, @rdturnermtl, @kprzybyla, @sobolevn, @kir0ul, @lmount, @jdufresne, @gsnsw-felixs and @alexwlchan.

About

Library-agnostic strategies for Array API adopters—now merged into Hypothesis!

https://hypothesis.readthedocs.io/en/latest/numpy.html#array-api

License:Other


Languages

Language:Python 100.0%Language:Makefile 0.0%