Skip to content

Commit 628ea2c

Browse files
update get_source_link to be plum compatible
1 parent 9e3b468 commit 628ea2c

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

fastcore/xtras.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,8 +429,8 @@ def exec_eval(code, # Code to exec/eval
429429
else: exec(code, g, l)
430430

431431
# %% ../nbs/03_xtras.ipynb
432-
def _is_type_dispatch(x): return type(x).__name__ == "TypeDispatch"
433-
def _unwrapped_type_dispatch_func(x): return x.first() if _is_type_dispatch(x) else x
432+
def _is_type_dispatch(x): return type(x).__name__ == "Function" # assumes plum-dispatch library is used
433+
def _unwrapped_type_dispatch_func(x): return x.methods[0].implementation if _is_type_dispatch(x) else x
434434

435435
def _is_property(x): return type(x)==property
436436
def _has_property_getter(x): return _is_property(x) and hasattr(x, 'fget') and hasattr(x.fget, 'func')

nbs/03_xtras.ipynb

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@
14401440
"text/markdown": [
14411441
"---\n",
14421442
"\n",
1443-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L385){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
1443+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L389){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
14441444
"\n",
14451445
"#### ReindexCollection\n",
14461446
"\n",
@@ -1451,7 +1451,7 @@
14511451
"text/plain": [
14521452
"---\n",
14531453
"\n",
1454-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L385){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
1454+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L389){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
14551455
"\n",
14561456
"#### ReindexCollection\n",
14571457
"\n",
@@ -1523,7 +1523,7 @@
15231523
"text/markdown": [
15241524
"---\n",
15251525
"\n",
1526-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L396){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
1526+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L400){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
15271527
"\n",
15281528
"###### ReindexCollection.reindex\n",
15291529
"\n",
@@ -1534,7 +1534,7 @@
15341534
"text/plain": [
15351535
"---\n",
15361536
"\n",
1537-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L396){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
1537+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L400){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
15381538
"\n",
15391539
"###### ReindexCollection.reindex\n",
15401540
"\n",
@@ -1623,7 +1623,7 @@
16231623
"text/markdown": [
16241624
"---\n",
16251625
"\n",
1626-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L400){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
1626+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L404){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
16271627
"\n",
16281628
"##### ReindexCollection.cache_clear\n",
16291629
"\n",
@@ -1634,7 +1634,7 @@
16341634
"text/plain": [
16351635
"---\n",
16361636
"\n",
1637-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L400){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
1637+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L404){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
16381638
"\n",
16391639
"##### ReindexCollection.cache_clear\n",
16401640
"\n",
@@ -1688,7 +1688,7 @@
16881688
"text/markdown": [
16891689
"---\n",
16901690
"\n",
1691-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L397){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
1691+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L401){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
16921692
"\n",
16931693
"##### ReindexCollection.shuffle\n",
16941694
"\n",
@@ -1699,7 +1699,7 @@
16991699
"text/plain": [
17001700
"---\n",
17011701
"\n",
1702-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L397){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
1702+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L401){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
17031703
"\n",
17041704
"##### ReindexCollection.shuffle\n",
17051705
"\n",
@@ -1896,8 +1896,8 @@
18961896
"outputs": [],
18971897
"source": [
18981898
"#|export\n",
1899-
"def _is_type_dispatch(x): return type(x).__name__ == \"TypeDispatch\"\n",
1900-
"def _unwrapped_type_dispatch_func(x): return x.first() if _is_type_dispatch(x) else x\n",
1899+
"def _is_type_dispatch(x): return type(x).__name__ == \"Function\" # assumes plum-dispatch library is used\n",
1900+
"def _unwrapped_type_dispatch_func(x): return x.methods[0].implementation if _is_type_dispatch(x) else x\n",
19011901
"\n",
19021902
"def _is_property(x): return type(x)==property\n",
19031903
"def _has_property_getter(x): return _is_property(x) and hasattr(x, 'fget') and hasattr(x.fget, 'func')\n",
@@ -2252,7 +2252,7 @@
22522252
"text/markdown": [
22532253
"---\n",
22542254
"\n",
2255-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L507){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
2255+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L530){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
22562256
"\n",
22572257
"#### EventTimer\n",
22582258
"\n",
@@ -2263,7 +2263,7 @@
22632263
"text/plain": [
22642264
"---\n",
22652265
"\n",
2266-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L507){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
2266+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L530){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
22672267
"\n",
22682268
"#### EventTimer\n",
22692269
"\n",
@@ -2377,7 +2377,7 @@
23772377
"text/markdown": [
23782378
"---\n",
23792379
"\n",
2380-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L539){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
2380+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L562){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
23812381
"\n",
23822382
"#### PartialFormatter\n",
23832383
"\n",
@@ -2388,7 +2388,7 @@
23882388
"text/plain": [
23892389
"---\n",
23902390
"\n",
2391-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L539){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
2391+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L562){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
23922392
"\n",
23932393
"#### PartialFormatter\n",
23942394
"\n",
@@ -2593,7 +2593,7 @@
25932593
"text/markdown": [
25942594
"---\n",
25952595
"\n",
2596-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L596){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
2596+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L619){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
25972597
"\n",
25982598
"#### ContextManagers\n",
25992599
"\n",
@@ -2604,7 +2604,7 @@
26042604
"text/plain": [
26052605
"---\n",
26062606
"\n",
2607-
"[source](https://github.com/fastai/fastcore/blob/master/fastcore/xtras.py#L596){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
2607+
"[source](https://github.com/AnswerDotAI/fastcore/blob/master/fastcore/xtras.py#L619){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
26082608
"\n",
26092609
"#### ContextManagers\n",
26102610
"\n",

0 commit comments

Comments
 (0)