-
-
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
Array conversion methods #9823
base: main
Are you sure you want to change the base?
Array conversion methods #9823
Conversation
I just want to note that conceptually this problem
is effectively a static typing check. Whilst in general an xarray Dataset arguably is a generic with type That's a similar problem to the one that comes up in VirtualiZarr, where users get confused by how there is no top-level " |
We talked about this at the Xarray developers meeting today. One concern is that I'm less sure that we need the capability to check all arrays to see if they match a given array type. We don't have that for dtypes, which suggests it may not be necessary. That said, I do think it would be nice to be able to generically flatten the data from an arbitrary xarray object into a list, to support something like I agree that these are not the most obvious APIs for working with duck array data, in particular because duck array conversion can only very loosely be interpreted as a numpy universal function. We could consider adding new methods for this, but I would start with documenting what we already have, e.g., in the documentation section on working with numpy-like arrays. |
Yeah that all makes sense. Should we close in favor of a simple documentation PR? |
whats-new.rst
api.rst
This implements a convenience method to convert data between duck array types, and another to check the current type of your data. Basically identical to cupy-xarray's
as_cupy()
/is_cupy()
methods, but exposed in a more general way.The signature I have here takes a callable plus any kwargs, so it's quite flexible:
Then:
I'm not sure about the naming. There are also other ways we could go about this, e.g. string matching for supported arrays.
Follow up to #9798.