Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Attributes get dropped on empty parent nodes #278

Closed
slevang opened this issue Nov 20, 2023 · 0 comments · Fixed by #279
Closed

Attributes get dropped on empty parent nodes #278

slevang opened this issue Nov 20, 2023 · 0 comments · Fixed by #279

Comments

@slevang
Copy link
Contributor

slevang commented Nov 20, 2023

When applying a function to a node that has attrs but no data:

dt = DataTree()
dt.attrs = {"foo": "bar"}
ds = xr.Dataset({"x": xr.DataArray(0)})
dt["y"] = DataTree(data=xr.DataArray(0, name="y"))

DataTree('None', parent=None)
│   Dimensions:  ()
│   Data variables:
│       *empty*Attributes:
│       foo:      bar
└── DataTree('y')
        Dimensions:  ()
        Data variables:
            y        int64 0

map_over_subtree drops the attributes:

dt.attrs
{'foo': 'bar'}

dt.compute().attrs
{}

Related: #262

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant