Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Using delegates on a method breaks TypeDispatch #538

Open
@warner-benjamin

Description

@warner-benjamin

Adding adelegates decorator to a method preventsTypeDispatch from creating the correct dispatching table.

Withoutdelegates, the dispatch forTensorAudio.create is correct:

classTensorAudio(TensorBase):@classmethoddefcreate(cls,fn:str|Path,**kwargs):sig,sr=torchaudio.load(fn,**kwargs)returncls(sig,sr=sr)

TypeDispatch(TensorAudio.create) returns

(str,object) -> create(Path,object) -> create

But with delegates,TypeDispatch doesn't create the correct dispatch table:

classTensorAudio(TensorBase):@delegates(torchaudio.load)@classmethoddefcreate(cls,fn:str|Path,**kwargs):sig,sr=torchaudio.load(fn,**kwargs)returncls(sig,sr=sr)TypeDispatch(TensorAudio.create)

InsteadTypeDispatch(TensorAudio.create) returns:

(str,BinaryIO) -> create(str,str) -> create(str,PathLike) -> create(Path,BinaryIO) -> create(Path,str) -> create(Path,PathLike) -> create

TheBinaryIO,str, andPathLike in the type dispatch are fromtorchaudio.load. It's missing(str,object) and(Path,object). This incorrect dispatch prevents fromTensorAudio.create dispatching in a fastai datablock.

Previous versions of fastcore did not have this interplay betweendelegates andTypeDispatch, but I am not sure when it cropped up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp