
try:
import pyodide_kernel
except ImportError:
print("This notebook is meant to be run in jupyterlite only !!!")
print("make sure you run myst **without** the --execute flag !")
print("Skipping execution of the rest of the notebook")
raisekernel version¶
import pyodide_kernel
pyodide_kernel.__version__Display¶
from IPython.display import HTML, JSON, Latex, MarkdownHTML¶
print("Before display")
s = "<h1>HTML Title</h1>"
display(HTML(s))
print("After display")Markdown¶
Markdown(
"""
# Title
**in bold**
~~Strikthrough~~
"""
)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 jsimport json
from js import fetchres = await fetch("https://httpbin.org/get")
text = await res.text()
obj = json.loads(text)
JSON(obj)Sympy¶
%pip install sympyfrom sympy import Integral, init_printing, sqrt, symbols
init_printing()
x = symbols("x")
Integral(sqrt(1 / x), x)