Skip to content

Commit 54b6f81

Browse files
committed
fixes #458
1 parent 726f373 commit 54b6f81

File tree

8 files changed

+56
-55
lines changed

8 files changed

+56
-55
lines changed

fastcore/_modidx.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
'author_email': '[email protected]',
88
'black_formatting': 'False',
99
'branch': 'master',
10+
'clean_ids': 'True',
1011
'copyright': 'fast.ai',
1112
'custom_sidebar': 'False',
1213
'description': 'Python supercharged for fastai development',
@@ -16,6 +17,7 @@
1617
'doc_path': '_docs',
1718
'git_url': 'https://github.com/fastai/fastcore/',
1819
'host': 'github',
20+
'jupyter_hooks': 'True',
1921
'keywords': 'python',
2022
'language': 'English',
2123
'lib_name': 'fastcore',
@@ -29,7 +31,7 @@
2931
'title': 'fastcore',
3032
'tst_flags': '',
3133
'user': 'fastai',
32-
'version': '1.5.15'},
34+
'version': '1.5.16'},
3335
'syms': { 'fastcore.all': {},
3436
'fastcore.basics': { 'fastcore.basics.AttrDict': 'https://fastcore.fast.ai/basics.html#attrdict',
3537
'fastcore.basics.AttrDict.copy': 'https://fastcore.fast.ai/basics.html#attrdict.copy',
@@ -398,13 +400,7 @@
398400
'fastcore.transform.get_func': 'https://fastcore.fast.ai/transform.html#get_func',
399401
'fastcore.transform.mk_transform': 'https://fastcore.fast.ai/transform.html#mk_transform'},
400402
'fastcore.utils': {},
401-
'fastcore.xdg': { 'fastcore.xdg.XDG_CACHE_HOME': 'https://fastcore.fast.ai/xdg.html#xdg_cache_home',
402-
'fastcore.xdg.XDG_CONFIG_DIRS': 'https://fastcore.fast.ai/xdg.html#xdg_config_dirs',
403-
'fastcore.xdg.XDG_CONFIG_HOME': 'https://fastcore.fast.ai/xdg.html#xdg_config_home',
404-
'fastcore.xdg.XDG_DATA_DIRS': 'https://fastcore.fast.ai/xdg.html#xdg_data_dirs',
405-
'fastcore.xdg.XDG_DATA_HOME': 'https://fastcore.fast.ai/xdg.html#xdg_data_home',
406-
'fastcore.xdg.XDG_RUNTIME_DIR': 'https://fastcore.fast.ai/xdg.html#xdg_runtime_dir',
407-
'fastcore.xdg.xdg_cache_home': 'https://fastcore.fast.ai/xdg.html#xdg_cache_home',
403+
'fastcore.xdg': { 'fastcore.xdg.xdg_cache_home': 'https://fastcore.fast.ai/xdg.html#xdg_cache_home',
408404
'fastcore.xdg.xdg_config_dirs': 'https://fastcore.fast.ai/xdg.html#xdg_config_dirs',
409405
'fastcore.xdg.xdg_config_home': 'https://fastcore.fast.ai/xdg.html#xdg_config_home',
410406
'fastcore.xdg.xdg_data_dirs': 'https://fastcore.fast.ai/xdg.html#xdg_data_dirs',

fastcore/xtras.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ def walk(
2727
symlinks:bool=True, # follow symlinks?
2828
keep_file:callable=noop, # function that returns True for wanted files
2929
keep_folder:callable=noop, # function that returns True for folders to enter
30+
skip_folder:callable=noop, # function that returns True for folders to skip
3031
func:callable=os.path.join # function to apply to each matched file
3132
): # Generator of `func` applied to matched files
3233
"Generator version of `os.walk`, using functions to filter files and folders"
3334
from copy import copy
3435
for root,dirs,files in os.walk(path, followlinks=symlinks):
35-
yield from (func(root, name) for name in files if keep_file(root,name))
36+
if keep_folder(root,''): yield from (func(root, name) for name in files if keep_file(root,name))
3637
for name in copy(dirs):
37-
if not keep_folder(root,name): dirs.remove(name)
38+
if skip_folder(root,name): dirs.remove(name)
3839

3940
# %% ../nbs/03_xtras.ipynb 9
4041
def globtastic(
@@ -61,10 +62,9 @@ def _keep_file(root, name):
6162
not file_re or file_re.search(name)) and (
6263
not skip_file_glob or not fnmatch(name, skip_file_glob)) and (
6364
not skip_file_re or not skip_file_re.search(name))
64-
def _keep_folder(root, name):
65-
return (not folder_re or folder_re.search(name)) and (
66-
not skip_folder_re or not skip_folder_re.search(name))
67-
return L(walk(path, symlinks=symlinks, keep_file=_keep_file, keep_folder=_keep_folder, func=func))
65+
def _keep_folder(root, name): return not folder_re or folder_re.search(os.path.join(root,name))
66+
def _skip_folder(root, name): return skip_folder_re and skip_folder_re.search(name)
67+
return L(walk(path, symlinks=symlinks, keep_file=_keep_file, keep_folder=_keep_folder, skip_folder=_skip_folder, func=func))
6868

6969
# %% ../nbs/03_xtras.ipynb 11
7070
@contextmanager

nbs/00_test.ipynb

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

nbs/01_basics.ipynb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@
771771
"Context manager to ignore exceptions"
772772
],
773773
"text/plain": [
774-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x110dfd850>"
774+
"<nbdev.showdoc.BasicMarkdownRenderer>"
775775
]
776776
},
777777
"execution_count": null,
@@ -893,7 +893,7 @@
893893
"Do nothing"
894894
],
895895
"text/plain": [
896-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x110dfb220>"
896+
"<nbdev.showdoc.BasicMarkdownRenderer>"
897897
]
898898
},
899899
"execution_count": null,
@@ -932,7 +932,7 @@
932932
"Do nothing (method)"
933933
],
934934
"text/plain": [
935-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x110e492b0>"
935+
"<nbdev.showdoc.BasicMarkdownRenderer>"
936936
]
937937
},
938938
"execution_count": null,
@@ -2600,7 +2600,7 @@
26002600
"Inherit from this to have all attr accesses in `self._xtra` passed down to `self.default`"
26012601
],
26022602
"text/plain": [
2603-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x110f29e20>"
2603+
"<nbdev.showdoc.BasicMarkdownRenderer>"
26042604
]
26052605
},
26062606
"execution_count": null,
@@ -4031,7 +4031,7 @@
40314031
"A `tuple` with elementwise ops and more friendly __init__ behavior"
40324032
],
40334033
"text/plain": [
4034-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a46c5e0>"
4034+
"<nbdev.showdoc.BasicMarkdownRenderer>"
40354035
]
40364036
},
40374037
"execution_count": null,
@@ -4106,7 +4106,7 @@
41064106
"`+` is already defined in `tuple` for concat, so use `add` instead"
41074107
],
41084108
"text/plain": [
4109-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a46e6d0>"
4109+
"<nbdev.showdoc.BasicMarkdownRenderer>"
41104110
]
41114111
},
41124112
"execution_count": null,
@@ -4146,7 +4146,7 @@
41464146
"`*` is already defined in `tuple` for replicating, so use `mul` instead"
41474147
],
41484148
"text/plain": [
4149-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a477160>"
4149+
"<nbdev.showdoc.BasicMarkdownRenderer>"
41504150
]
41514151
},
41524152
"execution_count": null,
@@ -4297,7 +4297,7 @@
42974297
"Same as `partial`, except you can use `arg0` `arg1` etc param placeholders"
42984298
],
42994299
"text/plain": [
4300-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a45ab80>"
4300+
"<nbdev.showdoc.BasicMarkdownRenderer>"
43014301
]
43024302
},
43034303
"execution_count": null,
@@ -5214,7 +5214,7 @@
52145214
"An `Enum` that can have its values imported"
52155215
],
52165216
"text/plain": [
5217-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a4ccca0>"
5217+
"<nbdev.showdoc.BasicMarkdownRenderer>"
52185218
]
52195219
},
52205220
"execution_count": null,
@@ -5268,7 +5268,7 @@
52685268
"An `ImportEnum` that behaves like a `str`"
52695269
],
52705270
"text/plain": [
5271-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a4d2730>"
5271+
"<nbdev.showdoc.BasicMarkdownRenderer>"
52725272
]
52735273
},
52745274
"execution_count": null,
@@ -5357,7 +5357,7 @@
53575357
"A base class/mixin for objects that should not serialize all their state"
53585358
],
53595359
"text/plain": [
5360-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a4dea30>"
5360+
"<nbdev.showdoc.BasicMarkdownRenderer>"
53615361
]
53625362
},
53635363
"execution_count": null,
@@ -5472,7 +5472,7 @@
54725472
"Little hack to get strings to show properly in Jupyter."
54735473
],
54745474
"text/plain": [
5475-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a4dcee0>"
5475+
"<nbdev.showdoc.BasicMarkdownRenderer>"
54765476
]
54775477
},
54785478
"execution_count": null,
@@ -5866,7 +5866,7 @@
58665866
"Same as `get_ipython` but returns `False` if not in IPython"
58675867
],
58685868
"text/plain": [
5869-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a486880>"
5869+
"<nbdev.showdoc.BasicMarkdownRenderer>"
58705870
]
58715871
},
58725872
"execution_count": null,
@@ -5895,7 +5895,7 @@
58955895
"Check if code is running in some kind of IPython environment"
58965896
],
58975897
"text/plain": [
5898-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a46ddc0>"
5898+
"<nbdev.showdoc.BasicMarkdownRenderer>"
58995899
]
59005900
},
59015901
"execution_count": null,
@@ -5924,7 +5924,7 @@
59245924
"Check if the code is running in Google Colaboratory"
59255925
],
59265926
"text/plain": [
5927-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a45c580>"
5927+
"<nbdev.showdoc.BasicMarkdownRenderer>"
59285928
]
59295929
},
59305930
"execution_count": null,
@@ -5953,7 +5953,7 @@
59535953
"Check if the code is running in a jupyter notebook"
59545954
],
59555955
"text/plain": [
5956-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a46c8e0>"
5956+
"<nbdev.showdoc.BasicMarkdownRenderer>"
59575957
]
59585958
},
59595959
"execution_count": null,
@@ -5982,7 +5982,7 @@
59825982
"Check if the code is running in a jupyter notebook"
59835983
],
59845984
"text/plain": [
5985-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11a4af5e0>"
5985+
"<nbdev.showdoc.BasicMarkdownRenderer>"
59865986
]
59875987
},
59885988
"execution_count": null,

nbs/03_xtras.ipynb

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,15 @@
8585
" symlinks:bool=True, # follow symlinks?\n",
8686
" keep_file:callable=noop, # function that returns True for wanted files\n",
8787
" keep_folder:callable=noop, # function that returns True for folders to enter\n",
88+
" skip_folder:callable=noop, # function that returns True for folders to skip\n",
8889
" func:callable=os.path.join # function to apply to each matched file\n",
8990
"): # Generator of `func` applied to matched files\n",
9091
" \"Generator version of `os.walk`, using functions to filter files and folders\"\n",
9192
" from copy import copy\n",
9293
" for root,dirs,files in os.walk(path, followlinks=symlinks):\n",
93-
" yield from (func(root, name) for name in files if keep_file(root,name))\n",
94+
" if keep_folder(root,''): yield from (func(root, name) for name in files if keep_file(root,name))\n",
9495
" for name in copy(dirs):\n",
95-
" if not keep_folder(root,name): dirs.remove(name)"
96+
" if skip_folder(root,name): dirs.remove(name)"
9697
]
9798
},
9899
{
@@ -126,10 +127,9 @@
126127
" not file_re or file_re.search(name)) and (\n",
127128
" not skip_file_glob or not fnmatch(name, skip_file_glob)) and (\n",
128129
" not skip_file_re or not skip_file_re.search(name))\n",
129-
" def _keep_folder(root, name):\n",
130-
" return (not folder_re or folder_re.search(name)) and (\n",
131-
" not skip_folder_re or not skip_folder_re.search(name))\n",
132-
" return L(walk(path, symlinks=symlinks, keep_file=_keep_file, keep_folder=_keep_folder, func=func))"
130+
" def _keep_folder(root, name): return not folder_re or folder_re.search(os.path.join(root,name))\n",
131+
" def _skip_folder(root, name): return skip_folder_re and skip_folder_re.search(name)\n",
132+
" return L(walk(path, symlinks=symlinks, keep_file=_keep_file, keep_folder=_keep_folder, skip_folder=_skip_folder, func=func))"
133133
]
134134
},
135135
{
@@ -140,7 +140,7 @@
140140
{
141141
"data": {
142142
"text/plain": [
143-
"(#9) ['./08_script.ipynb','./04_dispatch.ipynb','./06_docments.ipynb','./01_basics.ipynb','./fastcore/docments.py','./fastcore/dispatch.py','./fastcore/basics.py','./fastcore/docscrape.py','./fastcore/script.py']"
143+
"(#5) ['./fastcore/docments.py','./fastcore/dispatch.py','./fastcore/basics.py','./fastcore/docscrape.py','./fastcore/script.py']"
144144
]
145145
},
146146
"execution_count": null,
@@ -633,7 +633,7 @@
633633
{
634634
"data": {
635635
"text/plain": [
636-
"'pip 22.2 from /Users/jhoward/mambaforge/lib/python3.9/site-packages/pip (python 3.9)'"
636+
"'pip 22.2.1 from /Users/jhoward/mambaforge/lib/python3.9/site-packages/pip (python 3.9)'"
637637
]
638638
},
639639
"execution_count": null,
@@ -1273,7 +1273,7 @@
12731273
"### ReindexCollection\n",
12741274
"\n",
12751275
"> ReindexCollection (coll, idxs=None, cache=None,\n",
1276-
"> tfm=<functionnoopat0x106121940>)\n",
1276+
"> tfm=<functionnoopat0x103c44c10>)\n",
12771277
"\n",
12781278
"Reindexes collection `coll` with indices `idxs` and optional LRU cache of size `cache`"
12791279
],
@@ -1523,7 +1523,7 @@
15231523
{
15241524
"data": {
15251525
"text/plain": [
1526-
"['f', 'g', 'c', 'd', 'h', 'b', 'e', 'a']"
1526+
"['b', 'c', 'g', 'a', 'h', 'd', 'f', 'e']"
15271527
]
15281528
},
15291529
"execution_count": null,
@@ -1973,8 +1973,8 @@
19731973
"name": "stdout",
19741974
"output_type": "stream",
19751975
"text": [
1976-
"Num Events: 5, Freq/sec: 262.4\n",
1977-
"Most recent: ▇▃▁▃▆ 378.3 298.9 195.8 278.2 346.5\n"
1976+
"Num Events: 4, Freq/sec: 245.3\n",
1977+
"Most recent: ▃▁▁▁▇ 302.8 255.9 224.8 261.0 372.3\n"
19781978
]
19791979
}
19801980
],
@@ -2323,8 +2323,7 @@
23232323
"outputs": [],
23242324
"source": [
23252325
"#|hide\n",
2326-
"from nbdev import nbdev_export\n",
2327-
"nbdev_export()"
2326+
"import nbdev; nbdev.nbdev_export()"
23282327
]
23292328
},
23302329
{

nbs/03b_net.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
"Base class for client exceptions (code 4xx) from `url*` functions"
192192
],
193193
"text/plain": [
194-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11baaacd0>"
194+
"<nbdev.showdoc.BasicMarkdownRenderer>"
195195
]
196196
},
197197
"execution_count": null,
@@ -220,7 +220,7 @@
220220
"Base class for server exceptions (code 5xx) from `url*` functions"
221221
],
222222
"text/plain": [
223-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x11bac3400>"
223+
"<nbdev.showdoc.BasicMarkdownRenderer>"
224224
]
225225
},
226226
"execution_count": null,

nbs/05_transform.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
"Delegates (`__call__`,`decode`,`setup`) to (<code>encodes</code>,<code>decodes</code>,<code>setups</code>) if `split_idx` matches"
202202
],
203203
"text/plain": [
204-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x7f20641952e0>"
204+
"<nbdev.showdoc.BasicMarkdownRenderer>"
205205
]
206206
},
207207
"execution_count": null,
@@ -1335,7 +1335,7 @@
13351335
"\n"
13361336
],
13371337
"text/plain": [
1338-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x7f205e305220>"
1338+
"<nbdev.showdoc.BasicMarkdownRenderer>"
13391339
]
13401340
},
13411341
"execution_count": null,
@@ -1867,7 +1867,7 @@
18671867
"Compose `__call__` of all `fs` on `o`"
18681868
],
18691869
"text/plain": [
1870-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x7f205ddaa910>"
1870+
"<nbdev.showdoc.BasicMarkdownRenderer>"
18711871
]
18721872
},
18731873
"execution_count": null,
@@ -1896,7 +1896,7 @@
18961896
"Compose `decode` of all `fs` on `o`"
18971897
],
18981898
"text/plain": [
1899-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x7f205ddaa1c0>"
1899+
"<nbdev.showdoc.BasicMarkdownRenderer>"
19001900
]
19011901
},
19021902
"execution_count": null,
@@ -1925,7 +1925,7 @@
19251925
"Call each tfm's `setup` in order"
19261926
],
19271927
"text/plain": [
1928-
"<nbdev.showdoc.BasicMarkdownRenderer at 0x7f205e2a3eb0>"
1928+
"<nbdev.showdoc.BasicMarkdownRenderer>"
19291929
]
19301930
},
19311931
"execution_count": null,

settings.ini

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author = Jeremy Howard and Sylvain Gugger
77
author_email = [email protected]
88
copyright = fast.ai
99
branch = master
10-
version = 1.5.15
10+
version = 1.5.16
1111
min_python = 3.7
1212
audience = Developers
1313
language = English
@@ -23,4 +23,10 @@ title = fastcore
2323
doc_host = https://fastcore.fast.ai
2424
doc_baseurl = /
2525
host = github
26+
tst_flags =
27+
recursive = False
28+
black_formatting = False
29+
readme_nb = index.ipynb
30+
allowed_metadata_keys =
31+
allowed_cell_metadata_keys =
2632

0 commit comments

Comments
 (0)