MCPcopy Create free account
hub / github.com/ipython/ipython / _data_and_metadata

Method _data_and_metadata

IPython/core/display.py:1290–1309  ·  view source on GitHub ↗

shortcut for returning metadata with shape information, if defined

(self, always_both=False)

Source from the content-addressed store, hash-verified

1288 return {'text/html': self._repr_html_()}
1289
1290 def _data_and_metadata(self, always_both=False):
1291 """shortcut for returning metadata with shape information, if defined"""
1292 try:
1293 b64_data = b2a_base64(self.data).decode('ascii')
1294 except TypeError:
1295 raise FileNotFoundError(
1296 "No such file or directory: '%s'" % (self.data))
1297 md = {}
1298 if self.metadata:
1299 md.update(self.metadata)
1300 if self.width:
1301 md['width'] = self.width
1302 if self.height:
1303 md['height'] = self.height
1304 if self.unconfined:
1305 md['unconfined'] = self.unconfined
1306 if md or always_both:
1307 return b64_data, md
1308 else:
1309 return b64_data
1310
1311 def _repr_png_(self):
1312 if self.embed and self.format == self._FMT_PNG:

Callers 3

_repr_mimebundle_Method · 0.95
_repr_png_Method · 0.95
_repr_jpeg_Method · 0.95

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected