MCPcopy Create free account
hub / github.com/dask/dask / _repr_html_

Method _repr_html_

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

Source from the content-addressed store, hash-verified

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