File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7070 "metadata" : {},
7171 "outputs" : [],
7272 "source" : [
73+ " #|eval: false\n " ,
7374 " from fastcore.dispatch import typedispatch\n " ,
7475 " \n " ,
7576 " @typedispatch \n " ,
186187 }
187188 ],
188189 "source" : [
190+ " #|eval: false\n " ,
189191 " from fastcore.dispatch import TypeDispatch\n " ,
190192 " t_fc = TypeDispatch(fs)\n " ,
191193 " t_fc"
265267 }
266268 ],
267269 "source" : [
270+ " #|eval: false\n " ,
268271 " t_fc.add(lambda x: x**2)\n " ,
269272 " t_fc"
270273 ]
373376 " Before:"
374377 ]
375378 },
379+ {
380+ "cell_type" : " code" ,
381+ "execution_count" : null ,
382+ "id" : " ff9599da" ,
383+ "metadata" : {},
384+ "outputs" : [],
385+ "source" : [
386+ " def f_str(x:str): return x+'1'"
387+ ]
388+ },
376389 {
377390 "cell_type" : " code" ,
378391 "execution_count" : null ,
399412 }
400413 ],
401414 "source" : [
402- " def f_str(x:str): return x+'1'\n " ,
403- " \n " ,
415+ " #|eval: false\n " ,
404416 " t_fc2 = TypeDispatch(f_str, bases=t_fc)\n " ,
405417 " t_fc2"
406418 ]
539551 }
540552 ],
541553 "source" : [
554+ " #|eval: false\n " ,
542555 " t_fc[int]"
543556 ]
544557 },
559572 "metadata" : {},
560573 "outputs" : [],
561574 "source" : [
575+ " #|eval: false\n " ,
562576 " t_fc.returns(5)"
563577 ]
564578 },
661675 }
662676 ],
663677 "source" : [
678+ " #|eval: false\n " ,
664679 " @typedispatch\n " ,
665680 " def f2_fc(x:int|float): return x+2\n " ,
666681 " @typedispatch\n " ,
776791 }
777792 ],
778793 "source" : [
794+ " #|eval: false\n " ,
779795 " # Before (subclassing required)\n " ,
780796 " from fastcore.transform import Transform as FCTransform\n " ,
781797 " \n " ,
You can’t perform that action at this time.
0 commit comments