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

Method _repr_html_

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

Source from the content-addressed store, hash-verified

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