MCPcopy Index your code
hub / github.com/pydata/xarray / summarize_index

Function summarize_index

xarray/core/formatting.py:516–539  ·  view source on GitHub ↗
(
    names: tuple[Hashable, ...],
    index,
    col_width: int,
    max_width: int | None = None,
)

Source from the content-addressed store, hash-verified

514
515
516def summarize_index(
517 names: tuple[Hashable, ...],
518 index,
519 col_width: int,
520 max_width: int | None = None,
521) -> str:
522 if max_width is None:
523 max_width = OPTIONS["display_width"]
524
525 def prefixes(length: int) -> list[str]:
526 if length in (0, 1):
527 return [" "]
528
529 return ["┌"] + ["│"] * max(length - 2, 0) + ["└"]
530
531 preformatted = [
532 pretty_print(f" {prefix} {name}", col_width)
533 for prefix, name in zip(prefixes(len(names)), names, strict=True)
534 ]
535
536 head, *tail = preformatted
537 index_width = max_width - len(head)
538 repr_ = inline_index_repr(index, max_width=index_width)
539 return "\n".join([head + repr_] + [line.rstrip() for line in tail])
540
541
542def filter_nondefault_indexes(indexes, filter_indexes: bool):

Callers

nothing calls this directly

Calls 5

pretty_printFunction · 0.85
prefixesFunction · 0.85
inline_index_reprFunction · 0.85
rstripMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…