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

Function summarize_attr

xarray/core/formatting.py:364–373  ·  view source on GitHub ↗

Summary for __repr__ - use ``X.attrs[key]`` for full value.

(key, value, col_width=None)

Source from the content-addressed store, hash-verified

362
363
364def summarize_attr(key, value, col_width=None):
365 """Summary for __repr__ - use ``X.attrs[key]`` for full value."""
366 # Indent key and add ':', then right-pad if col_width is not None
367 k_str = f" {key}:"
368 if col_width is not None:
369 k_str = pretty_print(k_str, col_width)
370 # Replace tabs and newlines, so we print on one line in known width
371 v_str = str(value).replace("\t", "\\t").replace("\n", "\\n")
372 # Finally, truncate to the desired display width
373 return maybe_truncate(f"{k_str} {v_str}", OPTIONS["display_width"])
374
375
376EMPTY_REPR = " *empty*"

Callers 1

_diff_mapping_reprFunction · 0.85

Calls 3

pretty_printFunction · 0.85
maybe_truncateFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…