Skip to content

Latest commit

 

History

History
90 lines (70 loc) · 3 KB

numpy.rst

File metadata and controls

90 lines (70 loc) · 3 KB

Hypothesis for the scientific stack

numpy

Hypothesis offers a number of strategies for NumPy testing, available in the hypothesis[numpy] extra </extras>. It lives in the hypothesis.extra.numpy package.

The centerpiece is the ~hypothesis.extra.numpy.arrays strategy, which generates arrays with any dtype, shape, and contents you can specify or give a strategy for. To make this as useful as possible, strategies are provided to generate array shapes and generate all kinds of fixed-size or compound dtypes.

hypothesis.extra.numpy

pandas

Hypothesis provides strategies for several of the core pandas data types: pandas.Index, pandas.Series and pandas.DataFrame.

The general approach taken by the pandas module is that there are multiple strategies for generating indexes, and all of the other strategies take the number of entries they contain from their index strategy (with sensible defaults). So e.g. a Series is specified by specifying its numpy.dtype (and/or a strategy for generating elements for it).

hypothesis.extra.pandas

Supported versions

There is quite a lot of variation between pandas versions. We only commit to supporting the latest version of pandas, but older minor versions are supported on a "best effort" basis. Hypothesis is currently tested against and confirmed working with every Pandas minor version from 1.1 through to 2.0.

Releases that are not the latest patch release of their minor version are not tested or officially supported, but will probably also work unless you hit a pandas bug.

Array API

Hypothesis offers strategies for Array API adopting libraries in the hypothesis.extra.array_api package. See 3037 for more details. If you want to test with CuPy, Dask, JAX, MXNet, PyTorch <torch>, TensorFlow, or Xarray -or just NumPy - this is the extension for you!

hypothesis.extra.array_api.make_strategies_namespace

The resulting namespace contains all our familiar strategies like ~xps.arrays and ~xps.from_dtype, but based on the Array API standard semantics and returning objects from the xp module:

xps