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

Add a suite of property-based tests with Hypothesis #1846

Open
Zac-HD opened this issue Jan 21, 2018 · 3 comments
Open

Add a suite of property-based tests with Hypothesis #1846

Zac-HD opened this issue Jan 21, 2018 · 3 comments
Labels
topic-hypothesis Strategies or tests using the hypothesis library topic-testing

Comments

@Zac-HD
Copy link
Contributor

Zac-HD commented Jan 21, 2018

Hypothesis is a library for writing property-based tests in Python: you describe input data and make assertions that should be true for all examples, then Hypothesis tries to find a counterexample. This came up in #1840, because data == decode(encode(data)) is a classic property.

We could add a (initially small) suite of property-based tests, to complement the traditional example-based tests Xarray is already using. Keeping them in independent files will ensure that they run in CI but the dependency on Hypothesis remains optional for local development.

I have moved jobs and don't have time to do this myself, but I'd be very happy to help anyone who does 😄

@fmaussion
Copy link
Member

Reopening this issue as there is still a list of possible TODOs, as per @shoyer comment:

  • Consistency with pandas for groupby/rolling aggregations.
  • Roundtrip writing/reading data to netCDF. There are a couple of known exceptions (e.g., dtypes not supported by netCDF and MultiIndex) but otherwise every xarray object should be serializable to netCDF and back without data loss.
  • Roundtrip to/from pandas Series/DataFrame with to_series()/to_dataframe()/to_xarray().
  • Indexing consistency tests for backends: all indexing operations should be supported consistently on data accessed from any backend.
  • NumPy vs Dask: any operation on dask arrays should be consistent with the operation on numpy arrays (e.g., f(xarray_obj.chunk()).compute() == f(xarray_obj)).
  • Indexing followed by xarray.concat: should get back the same result.
  • Binary arithmetic on xarray objects with Python operators (+, -, etc) and NumPy ufuncs (np.add, np.subtract, etc).

@stale
Copy link

stale bot commented Feb 18, 2020

In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity

If this issue remains relevant, please comment here or remove the stale label; otherwise it will be marked as closed automatically

@stale stale bot added the stale label Feb 18, 2020
@max-sixty max-sixty removed the stale label Feb 18, 2020
@Zac-HD
Copy link
Contributor Author

Zac-HD commented Apr 21, 2020

@rdturnermtl wrote a Hypothesis extension for Xarray, which is at least a nice demo of what's possible.

If Xarray contributors want to keep working on this (#3283 seems stalled?) I'd be happy to help, since I'm both invested in Xarray working and would like to ship a hypothesis.extra.xarray some day 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-hypothesis Strategies or tests using the hypothesis library topic-testing
Projects
None yet
Development

No branches or pull requests

5 participants