Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Display

from IPython.display import HTML, JSON, Latex, Markdown
print("Imports successful")

kernel version

import pyodide_kernel
pyodide_kernel.__version__

HTML

print("Before display")

s = "<h1>HTML Title</h1>"
display(HTML(s))

print("After display")

Markdown

not exactly what one would expect yet

Markdown(
    """
# Title

**in bold**

~~Strikethrough~~
"""
)

Latex

Latex(
    r"""\begin{eqnarray}
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\
\nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
\nabla \cdot \vec{\mathbf{B}} & = 0
\end{eqnarray}"""
)

Matplotlib

Basic static plotting (temp patch)

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 1000)
plt.plot(x, np.sin(x))

plt.show()

Network requests and JSON

# %pip install js
import json

from js import fetch
res = await fetch("https://httpbin.org/get")
text = await res.text()
obj = json.loads(text)
JSON(obj)

Sympy

%pip install sympy
from sympy import Integral, init_printing, sqrt, symbols

init_printing()

x = symbols("x")

Integral(sqrt(1 / x), x)