Skip to content

Commit fecc737

Browse files
committed
update tutorial building workflow
1 parent 487133c commit fecc737

File tree

8 files changed

+69
-74
lines changed

8 files changed

+69
-74
lines changed

docs/tutorial/Makefile

Lines changed: 0 additions & 5 deletions
This file was deleted.

docs/tutorial/closer_look_at_plot_pos.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
"Additionally, we'll compute the plotting positions two different but commone ways for each plot.\n",
141141
"\n",
142142
"First, in blue circles, we'll show the data with Weibull (α=0, β=0) plotting positions.\n",
143-
"Weibull plotting positions are commonly use in my field, water resources engineering.\n",
143+
"Weibull plotting positions are commonly use in fields such as hydrology and water resources engineering.\n",
144144
"\n",
145145
"In green squares, we'll use Cunnane (α=0.4, β=0.4) plotting positions.\n",
146146
"Cunnane plotting positions are good for normally distributed data and are the default values."
@@ -280,9 +280,9 @@
280280
"metadata": {
281281
"anaconda-cloud": {},
282282
"kernelspec": {
283-
"display_name": "Python [default]",
283+
"display_name": "probscale",
284284
"language": "python",
285-
"name": "python3"
285+
"name": "probscale"
286286
},
287287
"language_info": {
288288
"codemirror_mode": {

docs/tutorial/closer_look_at_viz.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,9 @@
708708
"metadata": {
709709
"anaconda-cloud": {},
710710
"kernelspec": {
711-
"display_name": "Python [default]",
711+
"display_name": "probscale",
712712
"language": "python",
713-
"name": "python3"
713+
"name": "probscale"
714714
},
715715
"language_info": {
716716
"codemirror_mode": {

docs/tutorial/getting_started.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,9 +379,9 @@
379379
"metadata": {
380380
"anaconda-cloud": {},
381381
"kernelspec": {
382-
"display_name": "Python [default]",
382+
"display_name": "probscale",
383383
"language": "python",
384-
"name": "python3"
384+
"name": "probscale"
385385
},
386386
"language_info": {
387387
"codemirror_mode": {

docs/tutorial/make.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import os
2+
import glob
3+
4+
import nbformat
5+
from nbconvert import RSTExporter, preprocessors
6+
7+
8+
def cache(nbfile):
9+
basename, _ = os.path.splitext(nbfile)
10+
bakfile = basename + '.bak'
11+
with open(nbfile, 'r') as nb, open(bakfile, 'w') as bak:
12+
bak.write(nb.read())
13+
return bakfile
14+
15+
16+
def process(nbfile, processor):
17+
meta = {'metadata': {'path': '.'}}
18+
with open(nbfile, 'r') as nbf:
19+
nbook = nbformat.read(nbf, as_version=4)
20+
21+
runner = processor(timeout=600, kernel_name='probscale')
22+
runner.preprocess(nbook, meta)
23+
24+
with open(nbfile, 'w') as nbf:
25+
nbformat.write(nbook, nbf)
26+
27+
28+
def convert(nbfile):
29+
basename, _ = os.path.splitext(nbfile)
30+
img_folder = basename + '_files'
31+
os.makedirs(img_folder, exist_ok=True)
32+
print("\tconverting " + nbfile)
33+
34+
with open(nbfile, 'r') as nb:
35+
nbdata = nbformat.reads(nb.read(), as_version=4)
36+
37+
rst = RSTExporter()
38+
body_raw, images = rst.from_notebook_node(nbdata)
39+
body_final = body_raw.replace('.. image:: ', '.. image:: {}/'.format(img_folder))
40+
41+
with open(basename + '.rst', 'w') as rst_out:
42+
rst_out.write(body_final)
43+
44+
for img_name, img_data in images['outputs'].items():
45+
img_path = os.path.join(img_folder, img_name)
46+
with open(img_path, 'wb') as img:
47+
print('\twriting' + img_path)
48+
img.write(img_data)
49+
50+
51+
if __name__ == '__main__':
52+
for nbfile in glob.glob('*.ipynb'):
53+
bak = cache(nbfile)
54+
success = False
55+
try:
56+
process(nbfile, preprocessors.ExecutePreprocessor)
57+
convert(nbfile)
58+
success = True
59+
finally:
60+
process(nbfile, preprocessors.ClearOutputPreprocessor)
61+
if success:
62+
os.remove(bak)

docs/tutorial/tools/nb_to_doc.py

Lines changed: 0 additions & 27 deletions
This file was deleted.

docs/tutorial/tools/nbstripout

Lines changed: 0 additions & 31 deletions
This file was deleted.

probscale/viz.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,8 @@ def fit_line(x, y, xhat=None, fitprobs=None, fitlogs=None, dist=None,
421421
``lambda x: dist.ppf(x / 100.)``.
422422
For a log transform, ``lambda x: numpy.log(x)``.
423423
Take care to not pass the same value to both ``fitlogs`` and
424-
<<<<<<< 801b29f5fb36417255ee93a7fe704cc1360cb89c
425424
``figprobs`` as both transforms will be applied.
426425
427-
=======
428-
``fitprobs`` as both transforms will be applied.
429-
>>>>>>> fix minor doc typos
430426
dist : distribution, optional
431427
A fully-spec'd scipy.stats distribution-like object
432428
such that ``dist.ppf`` and ``dist.cdf`` can be called. If not

0 commit comments

Comments
 (0)