MCPcopy
hub / github.com/dask/dask / _repr_html_

Method _repr_html_

dask/array/core.py:1628–1655  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1626 )
1627
1628 def _repr_html_(self):
1629 if ARRAY_TEMPLATE is None:
1630 # if the jinja template is not available, (e.g. because jinja2 is not installed)
1631 # fall back to the textual representation
1632 return repr(self)
1633
1634 try:
1635 grid = self.to_svg(size=config.get("array.svg.size", 120))
1636 except NotImplementedError:
1637 grid = ""
1638
1639 if "sparse" in typename(type(self._meta)):
1640 nbytes = None
1641 cbytes = None
1642 elif not math.isnan(self.nbytes):
1643 nbytes = format_bytes(self.nbytes)
1644 cbytes = format_bytes(math.prod(self.chunksize) * self.dtype.itemsize)
1645 else:
1646 nbytes = "unknown"
1647 cbytes = "unknown"
1648
1649 return ARRAY_TEMPLATE.render(
1650 array=self,
1651 grid=grid,
1652 nbytes=nbytes,
1653 cbytes=cbytes,
1654 layers=maybe_pluralize(len(self.dask.layers), "graph layer"),
1655 )
1656
1657 @cached_property
1658 def ndim(self) -> int:

Callers 5

test_repr_htmlFunction · 0.45
test_html_reprFunction · 0.45

Calls 6

to_svgMethod · 0.95
typenameFunction · 0.90
format_bytesFunction · 0.90
maybe_pluralizeFunction · 0.90
getMethod · 0.45
prodMethod · 0.45

Tested by 5

test_repr_htmlFunction · 0.36
test_html_reprFunction · 0.36