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

Function children_section

xarray/core/formatting_html.py:554–585  ·  view source on GitHub ↗
(
    children: Mapping[str, DataTree], displays: dict[str, _DataTreeDisplay]
)

Source from the content-addressed store, hash-verified

552
553
554def children_section(
555 children: Mapping[str, DataTree], displays: dict[str, _DataTreeDisplay]
556) -> str:
557 child_elements = []
558 children_list = list(children.values())
559 nchildren = len(children_list)
560 max_children = int(OPTIONS["display_max_children"])
561
562 if nchildren <= max_children:
563 # Render all children
564 for i, child in enumerate(children_list):
565 is_last = i == nchildren - 1
566 child_elements.append(datatree_child_repr(child, displays, end=is_last))
567 else:
568 # Truncate: show first ceil(max/2), ellipsis, last floor(max/2)
569 first_n = ceil(max_children / 2)
570 last_n = max_children - first_n
571
572 child_elements.extend(
573 datatree_child_repr(children_list[i], displays, end=False)
574 for i in range(first_n)
575 )
576
577 child_elements.append(_ellipsis_element())
578
579 child_elements.extend(
580 datatree_child_repr(children_list[i], displays, end=(i == nchildren - 1))
581 for i in range(nchildren - last_n, nchildren)
582 )
583
584 children_html = "".join(child_elements)
585 return f"<div class='xr-children'>{children_html}</div>"
586
587
588def datatree_sections(

Callers 1

datatree_sectionsFunction · 0.85

Calls 4

datatree_child_reprFunction · 0.85
_ellipsis_elementFunction · 0.85
valuesMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…