-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake_pdf.py
64 lines (57 loc) · 1.38 KB
/
make_pdf.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
import sys
import nbconvert
import nbformat
Complex_Networks = [
"leggi_pdb",
"PCM_permute",
"ER_networks",
"real_net_analysis",
"laplacian_lab_07",
"open_network_growth_models",
]
Pattern_Recognition = [
"Pat_Rec_Lab_1",
"SwissRoll_PCA_MDS_LLE_IsoMap_tSNE_UMAP",
"clustering_examples",
"simple_perceptron",
"neuron_class",
"scikit_intro",
]
Models = [
"bigrams",
"trigrams",
"concatenated_network",
"convolutional_network",
"min-char-rnn",
"GPT",
"gpt_source",
'GAN',
]
Quantum_Computing = [
"prerequisites",
"teleportation",
"phase_estimation",
]
out_notebook = nbformat.v4.new_notebook()
subject = sys.argv[1].lower()
outext = ".pdf"
if subject == 'cn':
files = Complex_Networks
outfile = 'Complex_Networks'
elif subject == 'pr':
files = Pattern_Recognition
outfile = 'Pattern_Recognition'
elif subject == 'mnm':
files = Models
outfile = 'Models_and_Numerical_Methods'
outext = "-LAB.pdf"
elif subject == 'qc':
files = Quantum_Computing
outfile = 'Quantum_Computing'
outext = "-LAB.pdf"
for file in files:
temp_notebook = nbformat.read('./src/{}/{}.ipynb'.format(outfile, file), as_version=4)
out_notebook.cells.extend(temp_notebook.cells)
out_pdf = nbconvert.PDFExporter().from_notebook_node(out_notebook)[0]
with open(outfile+outext, 'wb') as f:
f.write(out_pdf)