-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
Milestone
Description
Is your feature request related to a problem? Please describe.
Having to deal with both xr.DataArray
AND xr.Dataset
leads to branching logic and additional tests all over the code.
Describe the solution you'd like
XarrayLike
is a type that is accepted as input to most functions. I'd like to propose XarrayLike
extended to unify the types, rather than just a static type check utilty. In essence it should act as a transformer on runtime to map the types to a single type. This way any code logic dealing with XarrayLike
can operate under a single-type assumption.
I think the resultant unified datatype should be xr.Dataset
because:
xr.DataArray
is, I believe, fully representable within a dataset. i.e. a dataset with one array. 1xr.Dataset
is already one half of the representable types ofXarrayLike
- I'm ignoring
pandas
for now as out of scope...
risks:
- refactoring required and code cleaning
- need to make sure functionality is not affected: luckily we have good coverage
benefits:
- less code bloat.
- any common utility function only needs to deal with one type.
- less adhoc branching logic - each branch logic has added chance of error.
- tests can focus more on internal logic rather than repeatedly testing for handling the two types.
Describe alternatives you've considered
- Standardize to
xr.DataArray
instead 1 - Honestly, if a
xr.DataArray
is fully representable by axr.Dataset
, then this is a hard solution to beat. Any alternative would have to be some other data structure that can interface between the two more smoothly thanxr.Dataset
inherently can.