-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
46 lines (33 loc) · 1.06 KB
/
setup.py
File metadata and controls
46 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
Shim IPython's display API onto PyScript so example code written in a
Jupyter/IPython idiom runs unmodified in the browser.
"""
import sys
import types
import js
from pyscript import window, HTML, display as _display
js.alert = window.alert
def display(*args, **kwargs):
return _display(
*args, **kwargs, target=__pyscript_display_target__,
)
ipython = types.ModuleType("IPython")
core = types.ModuleType("IPython.core")
core_display = types.ModuleType("IPython.core.display")
core_display.display = display
core_display.HTML = HTML
ipython.core = core
core.display = core_display
ipython.get_ipython = lambda: None
ipython.display = core_display
sys.modules["IPython"] = ipython
sys.modules["IPython.core"] = core
sys.modules["IPython.core.display"] = core_display
sys.modules["IPython.display"] = core_display
def heading(text, level=2):
display(HTML(f"<h{level}>{text}</h{level}>"), append=True)
def note(text):
display(HTML(f"<p>{text}</p>"), append=True)
import numpy as np
import matplotlib.pyplot as plt
rng = np.random.default_rng(7)