File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -813,6 +813,9 @@ def _replace_node(
813
813
if data is not _default :
814
814
self ._set_node_data (ds )
815
815
816
+ if self .parent is not None :
817
+ _deduplicate_inherited_coordinates (self , self .parent )
818
+
816
819
self .children = children
817
820
818
821
def _copy_node (
Original file line number Diff line number Diff line change @@ -1315,6 +1315,19 @@ def test_inherited_coords_with_index_are_deduplicated(self):
1315
1315
expected = xr .Dataset ({"foo" : ("x" , [4 , 5 ])})
1316
1316
assert_identical (child_dataset , expected )
1317
1317
1318
+ def test_deduplicated_after_setitem (self ):
1319
+ # regression test for GH #9601
1320
+ dt = DataTree .from_dict (
1321
+ {
1322
+ "/" : xr .Dataset (coords = {"x" : [1 , 2 ]}),
1323
+ "/b" : None ,
1324
+ }
1325
+ )
1326
+ dt ["b/x" ] = dt ["x" ]
1327
+ child_dataset = dt .children ["b" ].to_dataset (inherited = False )
1328
+ expected = xr .Dataset ()
1329
+ assert_identical (child_dataset , expected )
1330
+
1318
1331
def test_inconsistent_dims (self ):
1319
1332
expected_msg = _exact_match (
1320
1333
"""
You can’t perform that action at this time.
0 commit comments