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

Function _tree_item_count

xarray/core/formatting_html.py:458–469  ·  view source on GitHub ↗
(node: DataTree, cache: dict[int, int])

Source from the content-addressed store, hash-verified

456
457
458def _tree_item_count(node: DataTree, cache: dict[int, int]) -> int:
459 if id(node) in cache:
460 return cache[id(node)]
461
462 node_ds = node.to_dataset(inherit=False)
463 node_count = len(node_ds.variables) + len(node_ds.attrs)
464 child_count = sum(
465 _tree_item_count(child, cache) for child in node.children.values()
466 )
467 total = node_count + child_count
468 cache[id(node)] = total
469 return total
470
471
472@dataclass

Callers 1

_build_datatree_displaysFunction · 0.85

Calls 2

to_datasetMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…