Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

constrain the type of proposal in accep_reject_sample #1395

Open
janfb opened this issue Feb 20, 2025 · 0 comments
Open

constrain the type of proposal in accep_reject_sample #1395

janfb opened this issue Feb 20, 2025 · 0 comments
Labels
API changes This impacts the public API of the project (e.g. inference class). hackathon

Comments

@janfb
Copy link
Contributor

janfb commented Feb 20, 2025

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.

@janfb janfb added API changes This impacts the public API of the project (e.g. inference class). hackathon labels Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API changes This impacts the public API of the project (e.g. inference class). hackathon
Projects
None yet
Development

No branches or pull requests

1 participant