Skip to content

Commit 40eb135

Browse files
committed
fixes #157
1 parent 23842b2 commit 40eb135

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

fastcore/dispatch.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,17 +167,17 @@ def __call__(self, f):
167167
#nbdev_comment _all_=['cast']
168168

169169
# Cell
170-
def retain_meta(x, res, copy_meta=False):
170+
def retain_meta(x, res, as_copy=False):
171171
"Call `res.set_meta(x)`, if it exists"
172-
if hasattr(res,'set_meta'): res.set_meta(x, copy_meta=copy_meta)
172+
if hasattr(res,'set_meta'): res.set_meta(x, as_copy=as_copy)
173173
return res
174174

175175
# Cell
176-
def default_set_meta(self, x, copy_meta=False):
176+
def default_set_meta(self, x, as_copy=False):
177177
"Copy over `_meta` from `x` to `res`, if it's missing"
178178
if hasattr(x, '_meta') and not hasattr(self, '_meta'):
179179
meta = x._meta
180-
if copy_meta: meta = copy(meta)
180+
if as_copy: meta = copy(meta)
181181
self._meta = meta
182182
return self
183183

@@ -194,7 +194,7 @@ def cast(x, typ):
194194
return retain_meta(x, res)
195195

196196
# Cell
197-
def retain_type(new, old=None, typ=None, copy_meta=False):
197+
def retain_type(new, old=None, typ=None, as_copy=False):
198198
"Cast `new` to type of `old` or `typ` if it's a superclass"
199199
# e.g. old is TensorImage, new is Tensor - if not subclass then do nothing
200200
if new is None: return
@@ -204,7 +204,7 @@ def retain_type(new, old=None, typ=None, copy_meta=False):
204204
typ = old if isinstance(old,type) else type(old)
205205
# Do nothing the new type is already an instance of requested type (i.e. same type)
206206
if typ==NoneType or isinstance(new, typ): return new
207-
return retain_meta(old, cast(new, typ), copy_meta=copy_meta)
207+
return retain_meta(old, cast(new, typ), as_copy=as_copy)
208208

209209
# Cell
210210
def retain_types(new, old=None, typs=None):

nbs/04_dispatch.ipynb

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,9 +1319,9 @@
13191319
"outputs": [],
13201320
"source": [
13211321
"#export\n",
1322-
"def retain_meta(x, res, copy_meta=False):\n",
1322+
"def retain_meta(x, res, as_copy=False):\n",
13231323
" \"Call `res.set_meta(x)`, if it exists\"\n",
1324-
" if hasattr(res,'set_meta'): res.set_meta(x, copy_meta=copy_meta)\n",
1324+
" if hasattr(res,'set_meta'): res.set_meta(x, as_copy=as_copy)\n",
13251325
" return res"
13261326
]
13271327
},
@@ -1332,11 +1332,11 @@
13321332
"outputs": [],
13331333
"source": [
13341334
"#export\n",
1335-
"def default_set_meta(self, x, copy_meta=False):\n",
1335+
"def default_set_meta(self, x, as_copy=False):\n",
13361336
" \"Copy over `_meta` from `x` to `res`, if it's missing\"\n",
13371337
" if hasattr(x, '_meta') and not hasattr(self, '_meta'):\n",
13381338
" meta = x._meta\n",
1339-
" if copy_meta: meta = copy(meta)\n",
1339+
" if as_copy: meta = copy(meta)\n",
13401340
" self._meta = meta\n",
13411341
" return self"
13421342
]
@@ -1420,7 +1420,7 @@
14201420
"outputs": [],
14211421
"source": [
14221422
"#export\n",
1423-
"def retain_type(new, old=None, typ=None, copy_meta=False):\n",
1423+
"def retain_type(new, old=None, typ=None, as_copy=False):\n",
14241424
" \"Cast `new` to type of `old` or `typ` if it's a superclass\"\n",
14251425
" # e.g. old is TensorImage, new is Tensor - if not subclass then do nothing\n",
14261426
" if new is None: return\n",
@@ -1430,7 +1430,7 @@
14301430
" typ = old if isinstance(old,type) else type(old)\n",
14311431
" # Do nothing the new type is already an instance of requested type (i.e. same type)\n",
14321432
" if typ==NoneType or isinstance(new, typ): return new\n",
1433-
" return retain_meta(old, cast(new, typ), copy_meta=copy_meta)"
1433+
" return retain_meta(old, cast(new, typ), as_copy=as_copy)"
14341434
]
14351435
},
14361436
{
@@ -1551,13 +1551,14 @@
15511551
"output_type": "stream",
15521552
"text": [
15531553
"Converted 00_test.ipynb.\n",
1554-
"Converted 01_foundation.ipynb.\n",
1555-
"Converted 02_utils.ipynb.\n",
1556-
"Converted 03_dispatch.ipynb.\n",
1557-
"Converted 04_transform.ipynb.\n",
1558-
"Converted 05_logargs.ipynb.\n",
1559-
"Converted 06_meta.ipynb.\n",
1560-
"Converted 07_script.ipynb.\n",
1554+
"Converted 01_basics.ipynb.\n",
1555+
"Converted 02_foundation.ipynb.\n",
1556+
"Converted 03_xtras.ipynb.\n",
1557+
"Converted 04_dispatch.ipynb.\n",
1558+
"Converted 05_transform.ipynb.\n",
1559+
"Converted 06_logargs.ipynb.\n",
1560+
"Converted 07_meta.ipynb.\n",
1561+
"Converted 08_script.ipynb.\n",
15611562
"Converted index.ipynb.\n"
15621563
]
15631564
}

0 commit comments

Comments
 (0)