pydata / xarray

N-D labeled arrays and datasets in Python
https://xarray.dev
Apache License 2.0
3.63k stars 1.09k forks source link

Should `DataTree.orphan` act in-place? #9674

Open TomNicholas opened 1 month ago

TomNicholas commented 1 month ago

What is your issue?

DataTree.orphan remove the parent node from a tree, but modifies in-place. It has no return value, so it's already consistent with #9196. But it's not obvious to me whether or not the method should return a modified copy instead.

came up here https://github.com/pydata/xarray/pull/9666#discussion_r1815592203

cc @keewis @shoyer

shoyer commented 1 month ago

I have had similar thoughts.

The non-inplace version is currently spelled DataTree.copy(). But the name is not so intuitive.

Something like tree['child'].orphan(inherit=False) would be much cleaner than tree['child'].copy(inherit=False).