File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -463,8 +463,10 @@ def __init__(
463
463
464
464
super ().__init__ (name = name )
465
465
self ._set_node_data (_coerce_to_dataset (data ))
466
- self .parent = parent
467
- self .children = children
466
+
467
+ # shallow copy to avoid modifying arguments in-place (see GH issue #9196)
468
+ self .parent = parent .copy () if parent is not None else None
469
+ self .children = {name : child .copy () for name , child in children .items ()}
468
470
469
471
def _set_node_data (self , ds : Dataset ):
470
472
data_vars , coord_vars = _collect_data_and_coord_variables (ds )
@@ -770,7 +772,7 @@ def _replace_node(
770
772
if data is not _default :
771
773
self ._set_node_data (ds )
772
774
773
- self ._children = children
775
+ self .children = children
774
776
775
777
def copy (
776
778
self : DataTree ,
You can’t perform that action at this time.
0 commit comments