Skip to main content

Jupyter, JupyterLite, marimo, Observable Notebook integration for Mathics3

Project description

Mathics3 Module for notebook frontends

This library provides helper functions for integrating Mathics3 into notebook environments. Currently, it supports Jupyter(Lite), marimo, and Observable.

JupyterLite

See Mathics3 live project a project that uses this Python module in a live demo running under pyodidie.

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
%load_ext mathics3_kernel.frontend.jupyter

Usage is as simple as executing the above code in a notebook cell, and then Mathics3 code can be directly run in all subsequent cells. Here is a sample notebook that can be used with a local Jupyter installation.

marimo

from mathics3_kernel.frontend.marimo import mathics3

Then run Mathics3 code like so:

mathics3("ArcCos[0]")

See the examples directory for a sample notebook:

marimo edit --sandbox examples/marimo_notebook.py

It also works in marimo's pyodide-powered online environment, see https://marimo.io/p/@davidar/mathics for an example.

Observable

For other notebook environments, this library provides a generic interface:

from mathics3_kernel.frontend.generic import mathics3

See https://observablehq.com/@davidar/mathics for an example of how this can be used with Observable notebooks. This notebook loads the library with pyodide, then implements a simple interface in JavaScript:

async function mathics3(strings) {
  const [type, result] = await py`${mathics3_kernel}(${strings[0]})`
  if (type === "code") {
    return md`\`\`\`\n${result}\n\`\`\``;
  } else if (type === "math") {
    return tex.block`${result}`;
  } else if (type === "json") {
    return JSON.parse(result);
  } else if (type === "html") {
    return html`${result}`;
  } else {
    return result;
  }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mathics3_notebook_frontends-1.0.0.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mathics3_notebook_frontends-1.0.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file mathics3_notebook_frontends-1.0.0.tar.gz.

File metadata

File hashes

Hashes for mathics3_notebook_frontends-1.0.0.tar.gz
Algorithm Hash digest
SHA256 19315d8556f4604475044144d17d6905e660a4882c62373cd33f0b7f9556dfe6
MD5 d656bae9b3214280b0479e3cf2d89ab6
BLAKE2b-256 a626b39268b726ac9b88a84f06bc599950484ccf76a531f04b843787ce5e09d7

See more details on using hashes here.

File details

Details for the file mathics3_notebook_frontends-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mathics3_notebook_frontends-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff71d5972ffc3a65c378228889d80f95e8ee65779f4bd6687c3449a907342795
MD5 960f3138742e508c731f177a6cfceafa
BLAKE2b-256 e8be38bb970822c88c7ed8a4067b77d02db8e5d23516f5b0fe346574c3438298

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page