kpeeters / cadabra2

A field-theory motivated approach to computer algebra.
https://cadabra.science/
GNU General Public License v3.0
230 stars 37 forks source link

Fix: update Jupyter kernel send function #304

Closed fjebaker closed 3 months ago

fjebaker commented 3 months ago

Fixes an issue @inaki-ortizdelandaluce opened on a Dockerfile wrapper I maintain: https://github.com/fjebaker/cadabra-resources/issues/1

The Server API was updated some months ago, but not in the Jupyter kernel, leading to runtime errors.

I have been planning to revisit the Jupyter kernel, modernize it, and flesh out the features I never got round to implementing, but I am yet to find the time... hopefully soon!

kpeeters commented 3 months ago

Thanks. That change was made to enable users to change existing output cells; an example is in examples/ref_dynamical_updates.cnb. In essence, whenever you call display it will return the id of the output cell, and you can then update that output cell by calling display with the cell_id as parameter. The following block shows a single output cell with an updating counter (instead of 100 output cells):

out=0
for i in range(100):
   out=display(i, cell_id=out)

I think Jupyter can do this too, since version 5.1 of the Jupyter messaging protocol, with the update_display_data message type, as per https://jupyter-protocol.readthedocs.io/en/latest/messaging.html. This may be interesting to add to the Cadabra kernel.

fjebaker commented 3 months ago

Thanks for the explanation! And thanks for merging.

This may be interesting to add to the Cadabra kernel.

Agreed. I will keep that in mind when I attempt the rewrite!