MCPcopy Index your code
hub / github.com/pydata/xarray / _attach

Method _attach

xarray/core/treenode.py:141–157  ·  view source on GitHub ↗
(self, parent: Self | None, child_name: str | None = None)

Source from the content-addressed store, hash-verified

139 self._post_detach(parent)
140
141 def _attach(self, parent: Self | None, child_name: str | None = None) -> None:
142 if parent is not None:
143 if child_name is None:
144 raise ValueError(
145 "To directly set parent, child needs a name, but child is unnamed"
146 )
147
148 self._pre_attach(parent, child_name)
149 parentchildren = parent._children
150 assert not any(child is self for child in parentchildren), (
151 "Tree is corrupt."
152 )
153 parentchildren[child_name] = self
154 self._parent = parent
155 self._post_attach(parent, child_name)
156 else:
157 self._parent = None
158
159 def orphan(self) -> None:
160 """Detach this node from its parent."""

Callers 1

_set_parentMethod · 0.95

Calls 2

_pre_attachMethod · 0.95
_post_attachMethod · 0.95

Tested by

no test coverage detected