Skip to content

hypothesis-awkward

Hypothesis strategies for Awkward Arrays.

Hypothesis is a property-based testing library. Its strategies are Python functions that strategically generate test data that can fail test cases in pytest and other testing frameworks. Once a test fails, Hypothesis searches for the simplest sample that causes the same error. Hypothesis automatically explores edge cases; developers do not need to craft test data manually.

Property-based testing is useful for finding edge cases in array libraries and in code that uses them. In fact, Hypothesis strategies for NumPy and pandas data types are included in Hypothesis itself. Xarray provides strategies for its data structure. The Apache Arrow codebase has strategies for PyArrow, which are not officially documented in its API reference.

This package, hypothesis-awkward, is a collection of Hypothesis strategies for Awkward Array, which can represent a wide variety of layouts of nested, variable-length, and mixed-type data. The current version of this package includes strategies that generate samples with certain types of layouts. The goal is to develop strategies that can generate fully general Awkward Arrays with multiple options to control the layout, data types, missing values, masks, and other array attributes. These strategies can help close in on edge cases in tools that use Awkward Array, and Awkward Array itself.

Next steps: