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
I realised that if you want to add new children to a DataTree object, then while this works
dt[name] = new_child
and you can examine the children using
dt.children # returns {'name': child1, ...}
then actually this does not currently work
dt.children[name] = new_child
It would be nice to make this work, as I think setting with .children makes the intent much clearer.
It doesn't work because .children is a property that returns a dict - the only way you can update the .children is by replacing it entirely using the property setter, i.e.
dt.children = {'name': new_child}
This problem is analogous to how Dataset has ds.coords, which returns a proxy mapping object which has a __setitem__ method that allow modification in-place.
sort of related to #9204 , and came up whilst doing #9297
What is your issue?
I realised that if you want to add new children to a
DataTree
object, then while this worksdt[name] = new_child
and you can examine the children using
dt.children # returns {'name': child1, ...}
then actually this does not currently work
dt.children[name] = new_child
It would be nice to make this work, as I think setting with
.children
makes the intent much clearer.It doesn't work because
.children
is a property that returns a dict - the only way you can update the.children
is by replacing it entirely using the property setter, i.e.dt.children = {'name': new_child}
This problem is analogous to how
Dataset
hasds.coords
, which returns a proxy mapping object which has a__setitem__
method that allow modification in-place.sort of related to #9204 , and came up whilst doing #9297
cc @shoyer
The text was updated successfully, but these errors were encountered: