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

Function array_repr

xarray/core/formatting_html.py:328–364  ·  view source on GitHub ↗
(arr)

Source from the content-addressed store, hash-verified

326
327
328def array_repr(arr) -> str:
329 dims = OrderedDict((k, v) for k, v in zip(arr.dims, arr.shape, strict=True))
330 if hasattr(arr, "xindexes"):
331 indexed_dims = arr.xindexes.dims
332 else:
333 indexed_dims = {}
334
335 obj_type = f"xarray.{type(arr).__name__}"
336 arr_name = escape(repr(arr.name)) if getattr(arr, "name", None) else ""
337
338 header_components = [
339 f"<div class='xr-obj-type'>{obj_type}</div>",
340 f"<div class='xr-obj-name'>{arr_name}</div>",
341 format_dims(dims, indexed_dims),
342 ]
343
344 sections = [array_section(arr)]
345
346 if hasattr(arr, "coords"):
347 if arr.coords:
348 sections.append(coord_section(arr.coords))
349
350 if hasattr(arr, "xindexes"):
351 display_default_indexes = _get_boolean_with_default(
352 "display_default_indexes", False
353 )
354 xindexes = filter_nondefault_indexes(
355 _get_indexes_dict(arr.xindexes), not display_default_indexes
356 )
357 if xindexes:
358 indexes = _get_indexes_dict(arr.xindexes)
359 sections.append(index_section(indexes))
360
361 if arr.attrs:
362 sections.append(attr_section(arr.attrs))
363
364 return _obj_repr(arr, header_components, sections)
365
366
367def dataset_repr(ds) -> str:

Callers

nothing calls this directly

Calls 7

typeFunction · 0.85
format_dimsFunction · 0.85
array_sectionFunction · 0.85
_obj_reprFunction · 0.85
_get_indexes_dictFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…