MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / pprint_edges

Function pprint_edges

monai/utils/misc.py:730–741  ·  view source on GitHub ↗

Pretty print the head and tail ``n_lines`` of ``val``, and omit the middle part if the part has more than 3 lines. Returns: the formatted string.

(val: Any, n_lines: int = 20)

Source from the content-addressed store, hash-verified

728
729
730def pprint_edges(val: Any, n_lines: int = 20) -> str:
731 """
732 Pretty print the head and tail ``n_lines`` of ``val``, and omit the middle part if the part has more than 3 lines.
733
734 Returns: the formatted string.
735 """
736 val_str = pprint.pformat(val).splitlines(True)
737 n_lines = max(n_lines, 1)
738 if len(val_str) > n_lines * 2 + 3:
739 hidden_n = len(val_str) - n_lines * 2
740 val_str = val_str[:n_lines] + [f"\n ... omitted {hidden_n} line(s)\n\n"] + val_str[-n_lines:]
741 return "".join(val_str)
742
743
744def check_key_duplicates(ordered_pairs: Sequence[tuple[Any, Any]]) -> dict[Any, Any]:

Callers 2

_log_input_summaryFunction · 0.90
test_strMethod · 0.90

Calls 1

maxFunction · 0.85

Tested by 1

test_strMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…