xskillscore icon indicating copy to clipboard operation
xskillscore copied to clipboard

Check that `a` and `b` are xarray objects

Open bradyrx opened this issue 6 years ago • 3 comments

The docstrings for all deterministic functions claim that ndarrays (i.e. numpy arrays) can be passed through, but that isn't the case since a lot of the preprocessing and wrapper functions leverage xarray methods to set up the package. Given the prefix x for xskillscore, I think it would be reasonable to enforce that a and b have to be xarray objects.

We do this in climpred with a decorator:

https://github.com/bradyrx/climpred/blob/61e397bc07004e292af5b0798d4eca17be5dd263/climpred/checks.py#L19-L57

Which is then applied as a header to relevant functions:

https://github.com/bradyrx/climpred/blob/61e397bc07004e292af5b0798d4eca17be5dd263/climpred/prediction.py#L32-L41

This would be easy to port over to xskillscore and decorate all of the high-level functions with.

bradyrx avatar Oct 18 '19 02:10 bradyrx

Nevermind this just seems to be a consequence of my PR.

bradyrx avatar Oct 18 '19 03:10 bradyrx

_check_identical_xr_types is likely to get added in #277. Should help with this issue

raybellwaves avatar Feb 28 '21 17:02 raybellwaves

I would check that they are both xr, int and float are also sometimes handy to use, see #285

aaronspring avatar Aug 10 '21 14:08 aaronspring