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

Function datatree_child_repr

xarray/core/formatting_html.py:599–649  ·  view source on GitHub ↗
(
    node: DataTree,
    displays: dict[str, _DataTreeDisplay],
    end: bool,
)

Source from the content-addressed store, hash-verified

597
598
599def datatree_child_repr(
600 node: DataTree,
601 displays: dict[str, _DataTreeDisplay],
602 end: bool,
603) -> str:
604 # Wrap DataTree HTML representation with a tee to the left of it.
605 #
606 # Enclosing HTML tag is a <div> with :code:`display: inline-grid` style.
607 #
608 # Turns:
609 # [ title ]
610 # | details |
611 # |_____________|
612 #
613 # into (A):
614 # |─ [ title ]
615 # | | details |
616 # | |_____________|
617 #
618 # or (B):
619 # └─ [ title ]
620 # | details |
621 # |_____________|
622
623 vline_height = "1.2em" if end else "100%"
624
625 path = escape(node.path)
626 display = displays[node.path]
627
628 group_id = "group-" + str(uuid.uuid4())
629 collapsed = " checked" if display.collapsed else ""
630 tip = " title='Expand/collapse group'" if not display.disabled else ""
631
632 sections = datatree_sections(node, displays)
633 sections_html = _sections_repr(sections) if sections else ""
634
635 html = f"""
636 <div class='xr-group-box'>
637 <div class='xr-group-box-vline' style='height: {vline_height}'></div>
638 <div class='xr-group-box-hline'></div>
639 <div class='xr-group-box-contents'>
640 <input id='{group_id}' type='checkbox'{collapsed} />
641 <label for='{group_id}'{tip}>
642 {path}
643 <span>({display.item_count})</span>
644 </label>
645 {sections_html}
646 </div>
647 </div>
648 """
649 return "".join(t.strip() for t in html.split("\n"))
650
651
652def datatree_repr(node: DataTree) -> str:

Callers 1

children_sectionFunction · 0.85

Calls 5

datatree_sectionsFunction · 0.85
_sections_reprFunction · 0.85
stripMethod · 0.80
splitMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…