computationalmodelling/nbval

0.10.0 release captures output even when ';' is present

pgbarletta opened this issue · 3 comments

Hi,

I'd frequently add a semicolon to silence a notebook's output instead of sanitizing it, when I didn't care about the output but I did care about the cell actually running.
The new release seems to get the cell output, even when the semicolon is present, so when it compares that output against the saved cell, it finds a discrepancy:

Traceback:
Unexpected output fields from running code: {'text/plain'}

was this intended? I'm currently removing all the semicolons from my notebooks and sanitizing the outputs so the tests work again, but I thought this was an unexpected behaviour, so I wanted to ask.

Cheers,

I don't think that was intended. I see there's also now a PR adding a failing test (#195).

I'm a bit puzzled, though, because I thought this was up to the kernel - I thought nbval wouldn't receive an execute_result message, so it didn't need to do anything special to handle this.

I think 525a14f is the relevant change. I'm not familiar enough with the jupyter ecosystem to know what's going on under the hood here, but commenting out the new store_history=False line gets the test case in #195 passing for me locally.

Thanks for the detective work! That vaguely makes sense - IPython's Out[n] execution results are part of the history. But I don't see a good reason why telling it not to store input history would override hiding output.

I think this is a bug in IPython. Specifically, the code deciding whether to display output uses the latest history entry, and if that's not the cell currently executing, it can get this wrong (presumably in either direction). See here:

https://github.com/ipython/ipython/blob/855e4595b72d85679027ce253e687c20bbc24e84/IPython/core/displayhook.py#L84-L92

I don't think this has been reported yet, but I've only done a very superficial search for it. If someone else could check it and do a bug report, that would be valuable.