Set child nodes via DataTree.children
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What is your issue?
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
cc @shoyer
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the DataTree.children property and comparing it with the Dataset.coords proxy mapping mentioned in the issue. Verify the existing dt[name] = new_child behavior, then confirm that dt.children[name] = new_child updates the tree in place and add coverage for that usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100