(node: DataTree, cache: dict[int, int])
| 456 | |
| 457 | |
| 458 | def _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 |
no test coverage detected
searching dependent graphs…