-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Use to_numpy
in time decoding
#10081
base: main
Are you sure you want to change the base?
Conversation
c911894
to
f69ba29
Compare
@@ -102,6 +102,10 @@ def to_numpy( | |||
from xarray.core.indexing import ExplicitlyIndexed | |||
from xarray.namedarray.parallelcompat import get_chunked_array_type | |||
|
|||
if hasattr(data, "to_numpy"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the ugly bit. It's only to test that we are using the to_numpy
method instead of np.asarray
which would fail for cupy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keewis does this seem OK to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks @dcherian—not sure if you were looking for a review yet, but these changes look reasonable to me.
Thanks for the review @spencerkclark This just makes explicitly convert to numpy. Fully migrating to using duck arrays was more invasive and would conflict with existing PRs, so let's do that later. |
This is the smallest set of changes I could find to make our time decoding handle duck arrays. Really we just explicitly convert to numpy arrays using
to_numpy
. Note that the cftime code path uses Cython, and so, it requires numpyThe second (now-reverted) commit makes more invasive changes to avoid the numpy conversion if we can. I think it's best saved for a different PR.
cc @TomAugspurger
whats-new.rst
api.rst