Return HTML repr of an xarray object. If CSS is not injected (untrusted notebook), fallback to the plain text repr.
(obj, header_components, sections)
| 305 | |
| 306 | |
| 307 | def _obj_repr(obj, header_components, sections): |
| 308 | """Return HTML repr of an xarray object. |
| 309 | |
| 310 | If CSS is not injected (untrusted notebook), fallback to the plain text repr. |
| 311 | |
| 312 | """ |
| 313 | header = f"<div class='xr-header'>{''.join(h for h in header_components)}</div>" |
| 314 | |
| 315 | icons_svg, css_style = _load_static_files() |
| 316 | return ( |
| 317 | "<div>" |
| 318 | f"{icons_svg}<style>{css_style}</style>" |
| 319 | f"<pre class='xr-text-repr-fallback'>{escape(repr(obj))}</pre>" |
| 320 | "<div class='xr-wrap' style='display:none'>" |
| 321 | f"{header}" |
| 322 | f"{_sections_repr(sections)}" |
| 323 | "</div>" |
| 324 | "</div>" |
| 325 | ) |
| 326 | |
| 327 | |
| 328 | def array_repr(arr) -> str: |
no test coverage detected
searching dependent graphs…