-
Notifications
You must be signed in to change notification settings - Fork 291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clear_output from code #432
Comments
there currently isn’t. @takluyver can you point me to where this is specified in the protocol? do we already handle the request in the kernel but don’t provide an API in IRdisplay? |
I don't think we implement any part of it yet. It's pretty simple, though - there's no request/reply, just a display message emitted by code executing in the kernel. We should be able to add support without too much difficulty. |
I'd also like to point out that this feature would enable live animation via callbacks which in general are useful for visualizing algorithm behavior/progress. In the CS domain this has been identified as a useful way of enhancing understanding, for example see here. The embedded ability to visualize algorithm progress was one of the reasons we originally adopted IPython/Jupyter as our tool of choice for illustrating the usage of our toolkit. Would really appreciate it if this was supported in the near future. |
Hey, |
Sadly no, but it should be easy to do. Do you want to do a pair of PRs? You’d probably
As @takluyver said, the docs here: http://jupyter-client.readthedocs.io/en/latest/messaging.html#clear-output |
To be honest I am not sure I understand well enough how IRKernel works internally to make a PR. I found that in IJulia clear_output function looks like that: function clear_output(wait=false)
# flush pending stdio
flush_all()
empty!(displayqueue) # discard pending display requests
send_ipython(publish[], msg_reply(execute_msg::Msg, "clear_output",
Dict("wait" => wait)))
stdio_bytes[] = 0 # reset output throttling
end And flush_all is: function flush_all()
flush_cstdio() # flush writes to stdout/stderr by external C code
flush(stdout)
flush(stderr)
end As well as I know in r there is flush.console() but I'm not sure if that what would work here, maybe just dev.off() would be better. However I have hard time understanding what is pending display request in IRKernel and how to transalte this send_ipython to send_response. |
I don’t think we need to flush, as things aren’t asynchronous on our end. You could start with what I said above, the method you’d add would just contain the |
This is repeat of a question I posted on stack-overflow (no response there so hopefully someone here can help):
I am trying to incrementally plot a graph, animating the progress of an image registration process. In a Python notebook this is done by repeatedly plotting and clearing the output. A MWE:
The equivalent in R (missing the clear-output):
In practice the plots will not be created in a for-loop, these are callbacks from the computationally intensive image registration. I am using the for loop as the MWE.
Is it possible to programmatically clear the output using the ir kernel? If yes, how? If not, any suggestions on creating animations in the notebook. This needs to be an online solution - saving images and creating an animated gif is not relevant for this purpose.
For those curious about the specific goal, this is part of our development of Jupyter SimpleITK notebooks.
Any advice is much appreciated.
The text was updated successfully, but these errors were encountered: