generated from fastai/nbdev_template
- Notifications
You must be signed in to change notification settings - Fork 289
Open
Description
Adding a delegates decorator to a method prevents TypeDispatch from creating the correct dispatching table.
Without delegates, the dispatch for TensorAudio.create is correct:
class TensorAudio(TensorBase): @classmethod def create(cls, fn:str|Path, **kwargs): sig, sr = torchaudio.load(fn, **kwargs) return cls(sig, sr=sr)TypeDispatch(TensorAudio.create) returns
(str,object) -> create (Path,object) -> create But with delegates, TypeDispatch doesn't create the correct dispatch table:
class TensorAudio(TensorBase): @delegates(torchaudio.load) @classmethod def create(cls, fn:str|Path, **kwargs): sig, sr = torchaudio.load(fn, **kwargs) return cls(sig, sr=sr) TypeDispatch(TensorAudio.create)Instead TypeDispatch(TensorAudio.create) returns:
(str,BinaryIO) -> create (str,str) -> create (str,PathLike) -> create (Path,BinaryIO) -> create (Path,str) -> create (Path,PathLike) -> create The BinaryIO, str, and PathLike in the type dispatch are from torchaudio.load. It's missing (str,object) and (Path,object). This incorrect dispatch prevents from TensorAudio.create dispatching in a fastai datablock.
Previous versions of fastcore did not have this interplay between delegates and TypeDispatch, but I am not sure when it cropped up.
Metadata
Metadata
Assignees
Labels
No labels