Skip to content

Expose testing methods #754

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

Closed
spencerahill opened this issue Feb 9, 2016 · 6 comments
Closed

Expose testing methods #754

spencerahill opened this issue Feb 9, 2016 · 6 comments

Comments

@spencerahill
Copy link
Contributor

Similar to numpy's numpy.testing module, I would find it useful for xarray to expose some of its testing methods, particularly those in its base TestCase.

I imagine other folks whose packages and/or modules derive heavily from xarray would find this useful too. For now I am just copy-pasting xarray's code for these methods into my testing modules.

@jhamman
Copy link
Member

jhamman commented Feb 9, 2016

👍

@shoyer
Copy link
Member

shoyer commented Feb 10, 2016

Most of these are as simple as assert d1.identical(d2) or assert d1.equals(d2) (see here for more details on these methods). I'd be OK with adding these methods in a dedicated testing module, though.

@spencerahill
Copy link
Contributor Author

Indeed. I'm happy to do this sometime (eventually...), but if somebody ends up with a pressing need for this in the meantime, go for it. Thanks!

@jhamman
Copy link
Member

jhamman commented Apr 1, 2016

@spencerahill - have you made any progress here? If not we (@dgergel) may be able to help out.

@spencerahill
Copy link
Contributor Author

Thanks for the ping. Sorry, I haven't. I'm actually submitting my PhD thesis in ~2 months and then defending it this summer, so I won't be able to help much until August or September. So by all means, go for it.

@fmaussion
Copy link
Member

I'd be willing to prepare a PR, if this is still actual. Today I needed the *AllClose methods for my tests, I think it would be great to have these methods exposed.

I think I have an idea on how to proceed, but maybe I am underestimating the required amount of work.

Numpy for example has the np.allclose and np.testing.assert_allclose functions. Should xarray also have a xr.allclose function or are we happy with a xr.testing.assert_allclose alone? Also, the current xarray implementation has a different function for variables, datasets and coordinates: could these be merged in a generic assert_allclose which takes decisions on what to do based on the input type?

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

5 participants