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

Method _repr_html_

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

Source from the content-addressed store, hash-verified

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