Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataTree: Copy during assignment to child nodes? #9489

Open
TomNicholas opened this issue Sep 12, 2024 · 2 comments
Open

DataTree: Copy during assignment to child nodes? #9489

TomNicholas opened this issue Sep 12, 2024 · 2 comments
Labels
bug topic-DataTree Related to the implementation of a DataTree class

Comments

@TomNicholas
Copy link
Member

I think both of these should have the same behavior:

bart = xr.DataTree(name="Bart")
lisa = xr.DataTree(name="Lisa")
homer = xr.DataTree(name="Homer", children={"Bart": bart, "Lisa": lisa})
print(list(lisa.siblings))

homer2 = xr.DataTree(name="Homer")
homer2.children = {"Bart": bart, "Lisa": lisa}
print(list(lisa.siblings))
[]
['Bart']

@TomNicholas

Originally posted by @flamingbear in #9033 (comment)

@TomNicholas TomNicholas added bug topic-DataTree Related to the implementation of a DataTree class labels Sep 12, 2024
@TomNicholas
Copy link
Member Author

TomNicholas commented Sep 12, 2024

I'm pretty sure I know what's going on here: we currently copy inputs to the constructor but not to the .children setter. This is the assignment version of #9196 - calling a method on homer2 has the side-effect of also altering one of the inputs lisa.

This could probably be fixed as part of #9477.

@flamingbear
Copy link
Member

Let's be sure to include this doc update when this is complete either in #9477 or a doc PR update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug topic-DataTree Related to the implementation of a DataTree class
Projects
None yet
Development

No branches or pull requests

2 participants