Skip to content

Commit ace354d

Browse files
committed
Fix Failing tests
1 parent 10a14f1 commit ace354d

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

fastcore/dispatch.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def __init__(self, funcs=(), bases=()):
8181
self.funcs,self.bases = _TypeDict(),L(bases).filter(is_not(None))
8282
for o in L(funcs): self.add(o)
8383
self.inst = None
84+
self.owner = None
8485

8586
def add(self, f):
8687
"Add type `t` and function `f`"
@@ -109,10 +110,12 @@ def __call__(self, *args, **kwargs):
109110
f = self[tuple(ts)]
110111
if not f: return args[0]
111112
if self.inst is not None: f = MethodType(f, self.inst)
113+
elif self.owner is not None: f = MethodType(f, self.owner)
112114
return f(*args, **kwargs)
113115

114116
def __get__(self, inst, owner):
115117
self.inst = inst
118+
self.owner = owner
116119
return self
117120

118121
def __getitem__(self, k):

nbs/03_dispatch.ipynb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@
553553
{
554554
"data": {
555555
"text/markdown": [
556-
"<h4 id=\"TypeDispatch.add\" class=\"doc_header\"><code>TypeDispatch.add</code><a href=\"__main__.py#L10\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
556+
"<h4 id=\"TypeDispatch.add\" class=\"doc_header\"><code>TypeDispatch.add</code><a href=\"__main__.py#L11\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
557557
"\n",
558558
"> <code>TypeDispatch.add</code>(**`f`**)\n",
559559
"\n",
@@ -876,7 +876,7 @@
876876
{
877877
"data": {
878878
"text/markdown": [
879-
"<h4 id=\"TypeDispatch.__call__\" class=\"doc_header\"><code>TypeDispatch.__call__</code><a href=\"__main__.py#L32\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
879+
"<h4 id=\"TypeDispatch.__call__\" class=\"doc_header\"><code>TypeDispatch.__call__</code><a href=\"__main__.py#L33\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
880880
"\n",
881881
"> <code>TypeDispatch.__call__</code>(**\\*`args`**, **\\*\\*`kwargs`**)\n",
882882
"\n",
@@ -964,7 +964,7 @@
964964
{
965965
"data": {
966966
"text/markdown": [
967-
"<h4 id=\"TypeDispatch.returns\" class=\"doc_header\"><code>TypeDispatch.returns</code><a href=\"__main__.py#L20\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
967+
"<h4 id=\"TypeDispatch.returns\" class=\"doc_header\"><code>TypeDispatch.returns</code><a href=\"__main__.py#L21\" class=\"source_link\" style=\"float:right\">[source]</a></h4>\n",
968968
"\n",
969969
"> <code>TypeDispatch.returns</code>(**`x`**)\n",
970970
"\n",
@@ -1429,6 +1429,7 @@
14291429
"Converted 04_transform.ipynb.\n",
14301430
"Converted 05_logargs.ipynb.\n",
14311431
"Converted 06_meta.ipynb.\n",
1432+
"Converted 07_script.ipynb.\n",
14321433
"Converted index.ipynb.\n"
14331434
]
14341435
}

0 commit comments

Comments
 (0)