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

Function limit_lines

xarray/core/formatting.py:659–667  ·  view source on GitHub ↗

If the string is more lines than the limit, this returns the middle lines replaced by an ellipsis

(string: str, *, limit: int)

Source from the content-addressed store, hash-verified

657
658
659def limit_lines(string: str, *, limit: int):
660 """
661 If the string is more lines than the limit,
662 this returns the middle lines replaced by an ellipsis
663 """
664 lines = string.splitlines()
665 if len(lines) > limit:
666 string = "\n".join(chain(lines[: limit // 2], ["..."], lines[-limit // 2 :]))
667 return string
668
669
670def short_array_repr(array):

Callers 2

apply_variable_ufuncFunction · 0.90
short_data_reprFunction · 0.85

Calls 1

joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…