Closed
Description
What is your issue?
This is very obviously an issue using the repr from #9470:
In [20]: tree = DataTree(Dataset(coords={'x': [1, 2, 3]}))
In [21]: tree['/foo'] = DataTree(Dataset({'bar': ('x', [4, 5, 6])}))
In [22]: tree
Out[22]:
<xarray.DataTree>
Group: /
│ Dimensions: (x: 3)
│ Coordinates:
│ * x (x) int64 24B 1 2 3
└── Group: /foo
Dimensions: (x: 3)
Data variables:
bar (x) int64 24B 4 5 6
In [23]: tree * 2
Out[23]:
<xarray.DataTree>
Group: /
│ Dimensions: (x: 3)
│ Coordinates:
│ * x (x) int64 24B 1 2 3
└── Group: /foo
Dimensions: (x: 3)
Coordinates:
* x (x) int64 24B 1 2 3
Data variables:
bar (x) int64 24B 8 10 12
Instead, the result for tree * 2
should look like:
<xarray.DataTree>
Group: /
│ Dimensions: (x: 3)
│ Coordinates:
│ * x (x) int64 24B 1 2 3
└── Group: /foo
Dimensions: (x: 3)
Data variables:
bar (x) int64 24B 8 10 12
We probably also need to also revisit other Dataset methods that are ported to DataTree via map_over_subtree
(xref #9472). Some of these (e.g., arithmetic, aggregations) can likely easily be corrected simply by mapping over nodes with inherited=False
. Others (e.g., indexing) will need more careful consideration.