Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create hypothesis.extra.xarray #3948

Closed
raybellwaves opened this issue Apr 4, 2024 · 1 comment
Closed

Create hypothesis.extra.xarray #3948

raybellwaves opened this issue Apr 4, 2024 · 1 comment

Comments

@raybellwaves
Copy link

raybellwaves commented Apr 4, 2024

I use hypothesis.extra.pandas for creation of pandas.DataFrame. e.g. https://hypothesis.readthedocs.io/en/latest/numpy.html#hypothesis.extra.pandas.data_frames

from hypothesis.extra.pandas import column, data_frames
df = data_frames([column("A", dtype=int), column("B", dtype=float)]).example()

I would be great to have something similar for xarray. I'm not sure what the API would look like but here is a mock up

from hypothesis.extra.xarray import data_array, data_set
ds = data_set(
    [
        data_array("A", shape=(2, 2), dtype=int),
        data_array("B", shape=(2, 2), dtype=float),
    ]
).example()

which could wrap the numpy functions

import xarray as xr
from hypothesis.extra.numpy import arrays
xr.Dataset(
    {
        "A": xr.DataArray(arrays(dtype=int, shape=(2, 2)).example()),
        "B": xr.DataArray(arrays(dtype=float, shape=(2, 2)).example()),
    }
)
@Zac-HD
Copy link
Member

Zac-HD commented Apr 4, 2024

Hi, Ray - I'm a keen Xarray user myself, and have some good news: as of a few weeks ago, Xarray ships strategies themselves! The stable set is basically just Variables at the moment, but people are actively working on the rest of the key types and I'm optimistic about shipping something awesome in the coming weeks.

I'm also pretty excited about the new pattern of shipping the integrations on the upstream-library side rather than in Hypothesis itself - it's a great way to encourage more people to try property-based testing, and ensures that the maintainers with deep expertise in e.g. Xarray are the ones maintaining the integration. (by contrast, hypothesis.extra.django rather suffers from there being no Django users among the Hypothesis maintainers)

@Zac-HD Zac-HD closed this as completed Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants