MCPcopy
hub / github.com/pydata/xarray / subtree

Method subtree

xarray/core/treenode.py:396–413  ·  view source on GitHub ↗

Iterate over all nodes in this tree, including both self and all descendants. Iterates breadth-first. See Also -------- DataTree.subtree_with_keys DataTree.descendants group_subtrees

(self)

Source from the content-addressed store, hash-verified

394
395 @property
396 def subtree(self) -> Iterator[Self]:
397 """
398 Iterate over all nodes in this tree, including both self and all descendants.
399
400 Iterates breadth-first.
401
402 See Also
403 --------
404 DataTree.subtree_with_keys
405 DataTree.descendants
406 group_subtrees
407 """
408 # https://en.wikipedia.org/wiki/Breadth-first_search#Pseudocode
409 queue = collections.deque([self])
410 while queue:
411 node = queue.popleft()
412 yield node
413 queue.extend(node.children.values())
414
415 @property
416 def subtree_with_keys(self) -> Iterator[tuple[str, Self]]:

Callers

nothing calls this directly

Calls 1

valuesMethod · 0.45

Tested by

no test coverage detected