-
Notifications
You must be signed in to change notification settings - Fork 8
/
notebook.py
95 lines (70 loc) · 1.87 KB
/
notebook.py
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
"""
---
pandoctools:
profile: Kiwi
out: "*.ipynb"
# out: "*.pdf"
input: False
eval: True
echo: False
error: raise
...
"""
# %% Markdown cell that doesn't affect PyCharm code inspection and Atom+Hydrogen 'Run All':
"""
# Markdown to Jupyter notebook example
Here is a SugarTeX example with @eq:max and @fig:img.
See [PDF of this source](https://github.com/kiwi0fruit/sugartex/raw/master/sugartex.pdf) if you do not have [excellent Unicode support](https://github.com/kiwi0fruit/sugartex#atom-editor-with-full-unicode-support).
ˎˎ
˱∇ × [⠘B] - 1∕c ∂[⠘E]∕∂t ˳= 4π∕c [⠘j] ¦#
∇ ⋅ [⠘E]\ ˳= 4πρ ¦
∇ × [⠘E] + 1∕c ∂[⠘B]∕∂t ˳= [⠘0] ¦
∇ ⋅ [⠘B]\ ˳= 0 ˲
,ˎˎ{#eq:max}
where ˎ[⠘B], [⠘E], [⠘j]: ℝ⁴ → ℝ³ˎ – vector functions of the form
ˎ(t,x,y,z) ↦ [⠘f](t,x,y,z), [⠘f] = (f_˹x˺, f_˹y˺, f_˹z˺)ˎ.
![Sample image with cross-references.](https://avatars3.githubusercontent.com/u/19735117?s=460&v=4){#fig:img}
In this version of Pandoc image caption @fig:img works.
"""
# %% {echo=True}
from IPython.display import Markdown
import pandas as pd
import numpy as np
import tabulatehelper as th
df = pd.DataFrame(np.random.random(16).reshape(4, 4))
Markdown(f'''
{th.md_table(df)}
: Table {{#tbl:table1}}
''')
# %%
"""
Text and @tbl:table1
"""
# %% {input=True, eval=False, echo=True}
import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.random(16).reshape(4, 4))
df
# %% {r, echo=True} R cell:
"""
# R cell:
x <- c(10, 20)
x[1]
"""
# %%
"""
# Header
@{echo=True}
```r
x <- c(10, 20)
x[1]
```
"""
# %% {echo=True}
import math
Markdown(f'''
Markdown text with SugarTeX formula: ˎα^˱{math.pi:1.3f}˲ˎ.
It works because of the Markdown display option and SugarTeX Pandoc filter.
''')
# %% {input=True, eval=False, echo=True}
print('Hello!')