You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DataTree.from_dict supports DataTree and Dataset values.
It would be nice to also support DataArray and Variable objects with fully qualified paths. Similar to the Dataset constructor, we would need a separate coords argument.
I am thinking something like:
tree=DataTree.from_dict(
data_vars={'/a': a, '/child/b': b, '/child/grandchild/c': c},
coords={'/child/x': x},
)
where the values a, b, c and x are all DataArray objects (or anything supported in the Dataset constructor).
We could support this inside DataTree.from_dict by adding a new coords argument and renaming the first argument to data, i.e.,
where DataArrayLike is an alias for everything valid in the Dataset constructor (DataArray | Variable | tuple | Numeric).
We could also make a dedicated constructor for this, e.g., DataTree.from_array_dict. If we took this approach, I would consider renaming the existing from_dict constructor, e.g., to DataTree.from_dataset_dict.
What is your issue?
DataTree.from_dict
supportsDataTree
andDataset
values.It would be nice to also support
DataArray
andVariable
objects with fully qualified paths. Similar to theDataset
constructor, we would need a separatecoords
argument.I am thinking something like:
where the values
a
,b
,c
andx
are all DataArray objects (or anything supported in the Dataset constructor).We could support this inside
DataTree.from_dict
by adding a newcoords
argument and renaming the first argument todata
, i.e.,where
DataArrayLike
is an alias for everything valid in the Dataset constructor (DataArray | Variable | tuple | Numeric
).We could also make a dedicated constructor for this, e.g.,
DataTree.from_array_dict
. If we took this approach, I would consider renaming the existingfrom_dict
constructor, e.g., toDataTree.from_dataset_dict
.CC the usual DataTree crew: @TomNicholas @eni-awowale @flamingbear @owenlittlejohns
The text was updated successfully, but these errors were encountered: