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

Function _mapping_repr

xarray/core/formatting.py:385–428  ·  view source on GitHub ↗
(
    mapping,
    title,
    summarizer,
    expand_option_name,
    col_width=None,
    max_rows=None,
    indexes=None,
)

Source from the content-addressed store, hash-verified

383
384
385def _mapping_repr(
386 mapping,
387 title,
388 summarizer,
389 expand_option_name,
390 col_width=None,
391 max_rows=None,
392 indexes=None,
393):
394 if col_width is None:
395 col_width = _calculate_col_width(mapping)
396
397 summarizer_kwargs = defaultdict(dict)
398 if indexes is not None:
399 summarizer_kwargs = {k: {"is_index": k in indexes} for k in mapping}
400
401 summary = [f"{title}:"]
402 if mapping:
403 len_mapping = len(mapping)
404 if not _get_boolean_with_default(expand_option_name, default=True):
405 summary = [f"{summary[0]} ({len_mapping})"]
406 elif max_rows is not None and len_mapping > max_rows:
407 summary = [f"{summary[0]} ({max_rows}/{len_mapping})"]
408 first_rows = calc_max_rows_first(max_rows)
409 keys = list(mapping.keys())
410 summary += [
411 summarizer(k, mapping[k], col_width, **summarizer_kwargs[k])
412 for k in keys[:first_rows]
413 ]
414 if max_rows > 1:
415 last_rows = calc_max_rows_last(max_rows)
416 summary += [pretty_print(" ...", col_width) + " ..."]
417 summary += [
418 summarizer(k, mapping[k], col_width, **summarizer_kwargs[k])
419 for k in keys[-last_rows:]
420 ]
421 else:
422 summary += [
423 summarizer(k, v, col_width, **summarizer_kwargs[k])
424 for k, v in mapping.items()
425 ]
426 else:
427 summary += [EMPTY_REPR]
428 return "\n".join(summary)
429
430
431data_vars_repr = functools.partial(

Callers 3

coords_reprFunction · 0.85
inherited_coords_reprFunction · 0.85
indexes_reprFunction · 0.85

Calls 8

_calculate_col_widthFunction · 0.85
calc_max_rows_firstFunction · 0.85
calc_max_rows_lastFunction · 0.85
pretty_printFunction · 0.85
keysMethod · 0.80
itemsMethod · 0.80
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…