Skip to content

Commit c503dcc

Browse files
committed
spacing
1 parent f78b76b commit c503dcc

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

nbs/01_nbio.ipynb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"#|hide\n",
10-
"#|default_exp nbio"
9+
"#| hide\n",
10+
"#| default_exp nbio"
1111
]
1212
},
1313
{
@@ -25,7 +25,7 @@
2525
"metadata": {},
2626
"outputs": [],
2727
"source": [
28-
"#|export\n",
28+
"#| export\n",
2929
"from fastcore.basics import *\n",
3030
"from fastcore.imports import *\n",
3131
"\n",
@@ -40,7 +40,7 @@
4040
"metadata": {},
4141
"outputs": [],
4242
"source": [
43-
"#|hide\n",
43+
"#| hide\n",
4444
"import tempfile"
4545
]
4646
},
@@ -64,7 +64,7 @@
6464
"metadata": {},
6565
"outputs": [],
6666
"source": [
67-
"#|exports\n",
67+
"#| exports\n",
6868
"def _read_json(self, encoding=None, errors=None):\n",
6969
" return loads(Path(self).read_text(encoding=encoding, errors=errors))"
7070
]
@@ -158,7 +158,7 @@
158158
"metadata": {},
159159
"outputs": [],
160160
"source": [
161-
"#|export\n",
161+
"#| export\n",
162162
"class NbCell(AttrDict):\n",
163163
" def __init__(self, idx, cell):\n",
164164
" super().__init__(cell)\n",
@@ -195,7 +195,7 @@
195195
"metadata": {},
196196
"outputs": [],
197197
"source": [
198-
"#|export\n",
198+
"#| export\n",
199199
"def _dict2obj(d, list_func=list, dict_func=AttrDict):\n",
200200
" \"Convert (possibly nested) dicts (or lists of dicts) to `AttrDict`\"\n",
201201
" if isinstance(d, list): return list(map(_dict2obj, d))\n",
@@ -292,7 +292,7 @@
292292
"metadata": {},
293293
"outputs": [],
294294
"source": [
295-
"#|export\n",
295+
"#| export\n",
296296
"def read_nb(path):\n",
297297
" \"Return notebook at `path`\"\n",
298298
" res = dict2nb(_read_json(path, encoding='utf-8'))\n",
@@ -368,7 +368,7 @@
368368
"metadata": {},
369369
"outputs": [],
370370
"source": [
371-
"#|export\n",
371+
"#| export\n",
372372
"def new_nb(cells=None, meta=None, nbformat=4, nbformat_minor=5):\n",
373373
" \"Returns an empty new notebook\"\n",
374374
" return dict2nb(cells=cells or [],metadata=meta or {},nbformat=nbformat,nbformat_minor=nbformat_minor)"
@@ -450,7 +450,7 @@
450450
"metadata": {},
451451
"outputs": [],
452452
"source": [
453-
"#|export\n",
453+
"#| export\n",
454454
"def nb2dict(d, k=None):\n",
455455
" \"Convert parsed notebook to `dict`\"\n",
456456
" if k=='source': return d.splitlines(keepends=True)\n",
@@ -485,7 +485,7 @@
485485
"metadata": {},
486486
"outputs": [],
487487
"source": [
488-
"#|export\n",
488+
"#| export\n",
489489
"def nb2str(nb):\n",
490490
" \"Convert `nb` to a `str`\"\n",
491491
" if isinstance(nb, (AttrDict,list)): nb = nb2dict(nb)\n",
@@ -525,7 +525,7 @@
525525
"metadata": {},
526526
"outputs": [],
527527
"source": [
528-
"#|export\n",
528+
"#| export\n",
529529
"def write_nb(nb, path):\n",
530530
" \"Write `nb` to `path`\"\n",
531531
" new = nb2str(nb)\n",
@@ -598,7 +598,7 @@
598598
"metadata": {},
599599
"outputs": [],
600600
"source": [
601-
"#|hide\n",
601+
"#| hide\n",
602602
"import nbdev; nbdev.nbdev_export()"
603603
]
604604
},

nbs/02_shell.ipynb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"metadata": {},
77
"outputs": [],
88
"source": [
9-
"#|hide\n",
10-
"#|default_exp shell"
9+
"#| hide\n",
10+
"#| default_exp shell"
1111
]
1212
},
1313
{
@@ -25,7 +25,7 @@
2525
"metadata": {},
2626
"outputs": [],
2727
"source": [
28-
"#|export\n",
28+
"#| export\n",
2929
"from __future__ import annotations\n",
3030
"\n",
3131
"from fastcore.utils import *\n",
@@ -81,7 +81,7 @@
8181
"metadata": {},
8282
"outputs": [],
8383
"source": [
84-
"#|export\n",
84+
"#| export\n",
8585
"class _CustDisplayHook(DisplayHook):\n",
8686
" def write_output_prompt(self): pass\n",
8787
" def write_format_data(self, data, md_dict): pass\n",
@@ -100,7 +100,7 @@
100100
"metadata": {},
101101
"outputs": [],
102102
"source": [
103-
"#|export\n",
103+
"#| export\n",
104104
"class CaptureShell(InteractiveShell):\n",
105105
" displayhook_class = _CustDisplayHook\n",
106106
"\n",
@@ -141,7 +141,7 @@
141141
"metadata": {},
142142
"outputs": [],
143143
"source": [
144-
"#|export\n",
144+
"#| export\n",
145145
"@patch\n",
146146
"def run_cell(self:CaptureShell, raw_cell, store_history=False, silent=False, shell_futures=True, cell_id=None,\n",
147147
" stdout=True, stderr=True, display=True, timeout=None, verbose=False):\n",
@@ -689,7 +689,7 @@
689689
"metadata": {},
690690
"outputs": [],
691691
"source": [
692-
"#|export\n",
692+
"#| export\n",
693693
"def _out_stream(text, name): return dict(name=name, output_type='stream', text=text.splitlines(True))\n",
694694
"def _out_exc(e):\n",
695695
" ename = type(e).__name__\n",
@@ -729,7 +729,7 @@
729729
"metadata": {},
730730
"outputs": [],
731731
"source": [
732-
"#|export\n",
732+
"#| export\n",
733733
"@patch\n",
734734
"def run(self:CaptureShell,\n",
735735
" code:str, # Python/IPython code to run\n",
@@ -1278,7 +1278,7 @@
12781278
"metadata": {},
12791279
"outputs": [],
12801280
"source": [
1281-
"#|export\n",
1281+
"#| export\n",
12821282
"@patch\n",
12831283
"def cell(self:CaptureShell, cell, stdout=True, stderr=True, verbose=False):\n",
12841284
" \"Run `cell`, skipping if not code, and store outputs back in cell\"\n",
@@ -1504,7 +1504,7 @@
15041504
"metadata": {},
15051505
"outputs": [],
15061506
"source": [
1507-
"#|export\n",
1507+
"#| export\n",
15081508
"def _false(o): return False\n",
15091509
"\n",
15101510
"@patch\n",
@@ -1738,7 +1738,7 @@
17381738
"metadata": {},
17391739
"outputs": [],
17401740
"source": [
1741-
"#|export\n",
1741+
"#| export\n",
17421742
"@patch\n",
17431743
"def execute(self:CaptureShell,\n",
17441744
" src:str|Path, # Notebook path to read from\n",
@@ -1805,7 +1805,7 @@
18051805
"metadata": {},
18061806
"outputs": [],
18071807
"source": [
1808-
"#|export\n",
1808+
"#| export\n",
18091809
"@patch\n",
18101810
"def prettytb(self:CaptureShell, \n",
18111811
" fname:str|Path=None): # filename to print alongside the traceback\n",
@@ -1880,7 +1880,7 @@
18801880
"metadata": {},
18811881
"outputs": [],
18821882
"source": [
1883-
"#|hide\n",
1883+
"#| hide\n",
18841884
"# Trailing `;` stops data from being captured\n",
18851885
"res = CaptureShell().run('1+1;')\n",
18861886
"test_eq(res, [])\n",
@@ -1897,7 +1897,7 @@
18971897
"metadata": {},
18981898
"outputs": [],
18991899
"source": [
1900-
"#|hide\n",
1900+
"#| hide\n",
19011901
"# Streams are split on and keep newlines\n",
19021902
"res = CaptureShell().run(r\"print('a\\nb'); print('c\\n\\n'); print('d')\")\n",
19031903
"test_eq(res[0]['text'], ['a\\n', 'b\\n', 'c\\n', '\\n', '\\n', 'd\\n'])"
@@ -1909,7 +1909,7 @@
19091909
"metadata": {},
19101910
"outputs": [],
19111911
"source": [
1912-
"#|hide\n",
1912+
"#| hide\n",
19131913
"# Text mime data are split on and keep newlines\n",
19141914
"res = CaptureShell().run(r\"from IPython.display import Markdown; display(Markdown('a\\nb'))\")\n",
19151915
"test_eq(res[0]['data']['text/markdown'], ['a\\n', 'b'])"
@@ -1921,7 +1921,7 @@
19211921
"metadata": {},
19221922
"outputs": [],
19231923
"source": [
1924-
"#|hide\n",
1924+
"#| hide\n",
19251925
"# Binary image mime data are base64-encoded and end in a single `\\n`\n",
19261926
"\n",
19271927
"def _pil2b64(im): return b64encode(im._repr_png_()).decode()+'\\n'\n",
@@ -1938,7 +1938,7 @@
19381938
"metadata": {},
19391939
"outputs": [],
19401940
"source": [
1941-
"#|hide\n",
1941+
"#| hide\n",
19421942
"# `display_data` flushes stdout and stderr - in that order\n",
19431943
"res = CaptureShell().run(\"import sys; sys.stderr.write('Error!'); print(1); display(1)\")\n",
19441944
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n']},\n",
@@ -1952,7 +1952,7 @@
19521952
"metadata": {},
19531953
"outputs": [],
19541954
"source": [
1955-
"#|hide\n",
1955+
"#| hide\n",
19561956
"# Consecutive writes to stdout are grouped\n",
19571957
"res = CaptureShell().run('print(1); print(2); print(3)')\n",
19581958
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n', '2\\n', '3\\n']}])"
@@ -1964,7 +1964,7 @@
19641964
"metadata": {},
19651965
"outputs": [],
19661966
"source": [
1967-
"#|hide\n",
1967+
"#| hide\n",
19681968
"# Consecutive writes to stdout are grouped despite an intermediate write to stderr, which is captured after\n",
19691969
"res = CaptureShell().run(\"import sys; print(1); print(2); sys.stderr.write('Error!'); print(3)\")\n",
19701970
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n', '2\\n', '3\\n']},\n",
@@ -1977,7 +1977,7 @@
19771977
"metadata": {},
19781978
"outputs": [],
19791979
"source": [
1980-
"#|hide\n",
1980+
"#| hide\n",
19811981
"# `execute_result` is always last\n",
19821982
"res = CaptureShell().run(\"import sys; sys.stderr.write('Error!'); print(1); display(1); 1\")\n",
19831983
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n']},\n",
@@ -2081,7 +2081,7 @@
20812081
"metadata": {},
20822082
"outputs": [],
20832083
"source": [
2084-
"#|export\n",
2084+
"#| export\n",
20852085
"@call_parse\n",
20862086
"def exec_nb(\n",
20872087
" src:str, # Notebook path to read from\n",
@@ -2259,7 +2259,7 @@
22592259
"metadata": {},
22602260
"outputs": [],
22612261
"source": [
2262-
"#|hide\n",
2262+
"#| hide\n",
22632263
"import nbdev; nbdev.nbdev_export()"
22642264
]
22652265
},

0 commit comments

Comments
 (0)