-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Support DataArray objects and nested dicts in DataTree.from_dict #10658
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for adding this at @shoyer! Do you think it would be worth adding another round trip test for Here is what I did based on DataArray.from_dict
|
xarray/core/datatree.py
Outdated
|
||
Or equivalently from a dict of values coercible to DataArray objects: | ||
|
||
>>> dt2 = DataTree.from_dict({"/a": 1, "/b/c": 2, "/b/d": 3}, coords={"/x": 0}) |
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.
Is this supposed to create a group with the name"/a"
? On my end I am just seeing ('/', '/b')
and the data variable with the name "a"
.
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 example was supposed to show creating a variable "a". I've replaced this with something a bit more concrete to illustrate the intended usage.
772c6c8
to
1baf002
Compare
So unfortunately this doesn't work. The issue is that
I'm not sure it makes sense to combine both in a single function. In particular, there is some ambiguity about whether Instead, I think we should have a dedicated methods |
This PR adds three features to the
DataTree.from_dict
constructor:DataArray
objects and anything that can be coerced into aDataArray
via theDataset
constructor.coords
argument for explicitly specifying coordinates.Fixes #9539, #9486
whats-new.rst