File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 70
70
"metadata" : {},
71
71
"outputs" : [],
72
72
"source" : [
73
+ " #|eval: false\n " ,
73
74
" from fastcore.dispatch import typedispatch\n " ,
74
75
" \n " ,
75
76
" @typedispatch \n " ,
186
187
}
187
188
],
188
189
"source" : [
190
+ " #|eval: false\n " ,
189
191
" from fastcore.dispatch import TypeDispatch\n " ,
190
192
" t_fc = TypeDispatch(fs)\n " ,
191
193
" t_fc"
265
267
}
266
268
],
267
269
"source" : [
270
+ " #|eval: false\n " ,
268
271
" t_fc.add(lambda x: x**2)\n " ,
269
272
" t_fc"
270
273
]
373
376
" Before:"
374
377
]
375
378
},
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
+ },
376
389
{
377
390
"cell_type" : " code" ,
378
391
"execution_count" : null ,
399
412
}
400
413
],
401
414
"source" : [
402
- " def f_str(x:str): return x+'1'\n " ,
403
- " \n " ,
415
+ " #|eval: false\n " ,
404
416
" t_fc2 = TypeDispatch(f_str, bases=t_fc)\n " ,
405
417
" t_fc2"
406
418
]
539
551
}
540
552
],
541
553
"source" : [
554
+ " #|eval: false\n " ,
542
555
" t_fc[int]"
543
556
]
544
557
},
559
572
"metadata" : {},
560
573
"outputs" : [],
561
574
"source" : [
575
+ " #|eval: false\n " ,
562
576
" t_fc.returns(5)"
563
577
]
564
578
},
661
675
}
662
676
],
663
677
"source" : [
678
+ " #|eval: false\n " ,
664
679
" @typedispatch\n " ,
665
680
" def f2_fc(x:int|float): return x+2\n " ,
666
681
" @typedispatch\n " ,
776
791
}
777
792
],
778
793
"source" : [
794
+ " #|eval: false\n " ,
779
795
" # Before (subclassing required)\n " ,
780
796
" from fastcore.transform import Transform as FCTransform\n " ,
781
797
" \n " ,
You can’t perform that action at this time.
0 commit comments