Conversation
A native C++ Jupyter kernel (kernel/, "xmathilda") that embeds the evaluator
in process via the C ABI and lets xeus handle the Jupyter wire protocol -- no
Python dependency at run time. Complements the Tauri notebook as a standard-
ecosystem on-ramp.
- src/ffi/mathilda_ffi.{c,h}: library-resident cell evaluator
mathilda_ffi_eval_cell (multi-statement cells, Print->stream,
Head::tag->message, ;/Null suppression, $Line/%/Out[n] history,
Graphics->plot, Image, ?name->usage/names, expr+latex), plus
mathilda_ffi_is_complete and mathilda_ffi_complete. Emits the same NDJSON
events as repl.c's pipe mode; held in step by check-pipe-protocol and
kernel/test/ffi_cell_test.c.
- kernel/: xeus interpreter, CMake build, kernelspec, README, and tests
(ffi_cell_test.c for the C layer, kernel_test.py for the full Jupyter
round-trip). Validated end-to-end against xeus 6.0.6.
- MathildaXeus.command: clickable launcher that builds/installs the kernel
into a conda-forge xeus env and opens JupyterLab.
No $VersionNumber bump in this commit: src/version.h is mid-edit in a parallel
working session, so the bump + tag are deferred to avoid clobbering it.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A Plot3D surface shades each quad its own colour and overlays a grid wireframe.
graphics3d_to_plotly_json flushed a separate mesh3d trace on every colour change
(one per quad) and a separate scatter3d trace per Line[] wireframe segment, so a
single Plot3D became ~1,700 traces / ~300 KB of JSON. That many separate WebGL
objects hangs the browser tab of any Plotly front end — including the new xeus
Jupyter kernel, where it looked like the notebook "crashed".
Now the whole surface is ONE mesh3d trace carrying per-quad colour via Plotly's
facecolor array, and the whole wireframe is ONE scatter3d trace with segments
separated by JSON null. Plot3D[Sin[x+y],{x,0,3},{y,0,3}] drops from 1,680 traces
to 2 (and 305 KB to 152 KB); it renders identically. Benefits every consumer of
the serializer (xeus kernel, desktop sidecar, mobile FFI).
test_plot3d now asserts the payload stays compact: exactly one mesh3d trace, at
most one scatter3d trace, and a facecolor array (per-quad shading preserved).
No $VersionNumber bump: src/version.h is mid-edit in a parallel session.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
Closing as already merged: this branch's content is already fully on The two commits here landed on
Verification: all 15 files are byte-identical to No action needed; the xeus Jupyter kernel (#78) is shipped. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A native xeus-based Jupyter kernel for Mathilda (addresses #78), built and
validated end-to-end against xeus 6.0.6. It embeds the evaluator in process via
Mathilda's C ABI and lets xeus handle the Jupyter wire protocol — no Python
dependency at run time. It's an interop on-ramp to the standard Jupyter
ecosystem (Lab / Notebook / VS Code / Colab) and complements the Tauri desktop
notebook in
frontend/.What's here
src/ffi/mathilda_ffi.{c,h}— a library-resident cell evaluatormathilda_ffi_eval_cell: multi-statement cells,Print→stream,Head::tag→message,;/Nullsuppression,$Line/%/Out[n]history,Graphics→Plotly,Image,?name→usage/names, results with KaTeX LaTeX.Plus
mathilda_ffi_is_completeandmathilda_ffi_complete. It emits thesame NDJSON events as
repl.c's pipe mode, kept in step bymake check-pipe-protocolandkernel/test/ffi_cell_test.c.kernel/— the xeus interpreter, CMake build, kernelspec, README, andtests (
ffi_cell_test.cfor the C layer;kernel_test.pyfor a full Jupyterround-trip via
jupyter_client).MathildaXeus.command— a clickable launcher that builds/installs thekernel into a conda-forge xeus env and opens JupyterLab.
Validation
kernel/test/kernel_test.py(jupyter_client) andkernel/test/ffi_cell_test.cboth pass:
Integrate[x^2,x]→$\frac{1}{3}\,x^{3}$, multi-statement +Print,1/0→Power::infyon stderr, syntax-error status,Plot[...]→Plotly,completion,
?nameinspect,is_complete,%history.make check-pipe-protocoland
make check-c99stay green.Notes for the reviewer / merge
$VersionNumberbump in these commits:src/version.hwas mid-edit ina parallel working session when this was branched, so the bump + tag were
deferred. Please bump
src/version.h(+0.001) and tag on merge, per CLAUDE.md.main(PR GraphPlot rewritten as a layout engine; new HypergraphPlot ; v0.237 #83 landed meanwhile),but the changes are disjoint from those commits, so the merge is
conflict-free.
kernel/README.md):image/pngforImage[], aself-contained HTML+plotly.js fallback, and true mid-computation interrupt.
🤖 Generated with Claude Code