Skip to content

constrain the type of proposal in accep_reject_sample #1395

@janfb

Description

@janfb

with #1370 we changed the type of the proposal argument to accept_reject_sample to be Callable instead of torch.Distribution to enable passing a sample function directly.

#1370 (comment)

However, it is not controlled whether this callable function behaves like a sample function, e.g., whether it takes a sample_shape as argument. Thus, we have to bypass the type checker here.

As a solution, I suggest defining a protocal that has a callable method with sample_shape-like input argument.

Note, this kind of approach could also apply to the way we handle potential_fns, i.e., using Python protocols instead of abstract base classes for controlling the types.

To be discussed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    API changesThis impacts the public API of the project (e.g. inference class).architectureInternal changes without API consequenceshackathon

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions