xarray-contrib / xskillscore

Metrics for verifying forecasts
https://xskillscore.readthedocs.io/en/stable/
Apache License 2.0
224 stars 40 forks source link

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

Open bradyrx opened 5 years ago

bradyrx commented 5 years ago

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 commented 5 years ago

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

raybellwaves commented 3 years ago

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

aaronspring commented 3 years ago

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