Skip to content

Commit 7f92174

Browse files
authored
Merge pull request #365 from martindurant/display_int
Directly alter notebook cell output
2 parents 8a4888a + c6ca2bf commit 7f92174

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

streamz/core.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,10 @@ def __str__(self):
333333

334334
__repr__ = __str__
335335

336-
def _ipython_display_(self, **kwargs):
336+
def _ipython_display_(self, **kwargs): # pragma: no cover
337337
try:
338338
from ipywidgets import Output
339-
import IPython
339+
from IPython.core.interactiveshell import InteractiveShell
340340
except ImportError:
341341
if hasattr(self, '_repr_html_'):
342342
return self._repr_html_()
@@ -350,8 +350,10 @@ def update_cell(val):
350350
if output is None:
351351
return
352352
with output:
353-
IPython.display.clear_output(wait=True)
354-
IPython.display.display(val)
353+
content, *_ = InteractiveShell.instance().display_formatter.format(val)
354+
output.outputs = ({'output_type': 'display_data',
355+
'data': content,
356+
'metadata': {}},)
355357

356358
s = self.map(update_cell)
357359
_html_update_streams.add(s)

0 commit comments

Comments
 (0)