Quantcast
Channel: Jupyter Blog - Medium
Viewing all articles
Browse latest Browse all 315

A Jupyter kernel for GNU Octave

$
0
0

GNU Octave is a long-standing member of the scientific computing ecosystem, featuring a mathematics-oriented syntax with built-in 2D/3D plotting and visualization tools, and compatible with the Matlab syntax. It is a natural candidate for high-quality integration in the Jupyter ecosystem.

Jupyter has been devised with language agnosticism in mind since it was spun off from the IPython project. The Kernel (the part of the infrastructure responsible for executing the code input by the user) is a key extension point to Jupyter, and dozens of language kernels exist in the ecosystem.

Prior art on Jupyter / GNU Octave integration includes the Calysto/Octave_kernel project by Steven Silvester (who is also a core Jupyter maintainer and the co-creator of JupyterLab). This existing kernel is part of the family of kernels built on top of the ipykernel reference implementation of the Jupyter protocol, in Python.

Today, we are happy to announce the xeus-octave project, a Jupyter kernel for GNU Octave. Xeus-octave was created by Giulio Girardi, recently joined by Antoine Prouvost — and has been incorporated into the Project Jupyter governance.

Xeus-octave is built upon the Xeus library, a C++ implementation of the Jupyter kernel protocol that enables fast development of new kernels using programming languages’ native APIs, unlocking new possibilities without parsing standard outputs or requiring a Python interpreter at runtime. After all, a Jupyter kernel is merely an executable providing a well-defined communication protocol. It is not bound to Python APIs.

A fully-featured kernel

We strove to make the xeus-octave kernel as complete as possible for this first iteration.

Multiple graphical toolkits

Notebook

A notebook Octave graphical toolkit can be used to render plots natively, and present the figure as an image in the notebook.

Screenshot of GNU Octave in action in Jupyter with the native Octave plots
The classic Octave sombrero plot rendered as an image inside the notebook

Plotly

An experimental plotly Octave graphical toolkit can also use Plotly to render code in the browser, with dynamic views, zooms, and hover tooltips.

Screenshot of GNU Octave in action in Jupyter with the Plotly  plots
Multiple plots rendered in a single plotly figure

Rich display

The kernel binds with the C++ interface of GNU Octave to provide a complete Octave experience. Having access to the exact internal type of the objects, xeus-octave can present data with rich output.

Matrices can be presented as HTML or LaTeX tables.

Screenshot of GNU Octave in action in Jupyter with the rich rendering of matrices

Symbolic expressions can be presented as LaTeX formulas.

Screenshot of GNU Octave in action in Jupyter with the rich rendering of equations

Structured data can be visualized as interactive tree views

Screenshot of GNU Octave in action in Jupyter with the rich rendering of Octave structured data as interactive tree views.

Interactive help

Formatted help, extracted from the GNU Octave reference manual, can be queried using the ? syntax.

Screenshot of GNU Octave in action in Jupyter with the interactive help displayed in an output cell

Trying it online

You can try the new Jupyter kernel for GNU Octave by clicking on the link below:

Logo of Binder

The Binder linked above includes examples of notebooks in the fields of Electronics, demonstrating the usability of xeus-octave in real-life complex scenarios.

This interactive demo is also featured on the Jupyter website at https://jupyter.org/try#kernels.

Installing xeus-octave

Xeus-octave has been packaged on conda-forge and can be installed with mamba or conda.

$ mamba install xeus-octave -c conda-forge

Future Work

In future iterations, we will work towards consolidating the xeus-octave experience, by adding cell magics and improving the Plotly integration.

A major ongoing development is the implementation of an Octave backend for Jupyter interactive widgets, based on the xwidgets project. Combined with Voilà, it will be possible to use GNU Octave to create standalone web dashboards.

Another ongoing endeavor is to port a growing portion of the scientific computing stack to WebAssembly (using the emscripten-forge project). Producing a Wasm build of GNU Octave will enable its use with Jupyterlite, enabling large-scale deployments on websites, blogs, and arbitrary web pages without any need for scalable cloud infrastructure.

About the authors

Headshot of Antoine Prouvost

Antoine Prouvost is a Scientific Software Engineer at QuantStack and a xeus-octave maintainer. Previously, Antoine was researching Machine Learning and Combinatorial Optimization at the DS4DM research chair and Mila.

Headshot of Giulio Girardi

Giulio Girardi is a Master’s degree student in Electronic Engineering at the UNIPD, currently working as an Electronic Engineer at Protech Engineering. Giulio is the creator and a maintainer of the xeus-octave project.


A Jupyter kernel for GNU Octave was originally published in Jupyter Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.


Viewing all articles
Browse latest Browse all 315

Trending Articles