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

fix: make RestrictedPrior a distribution; extend test #1257

Merged
merged 1 commit into from
Sep 3, 2024

Conversation

janfb
Copy link
Contributor

@janfb janfb commented Sep 3, 2024

What does this implement/fix? Explain your changes

Make RestrictedPrior a proper torch.Distribution with the required methods. The support is taken from the underlying base prior, or raised as not implemented.
This is fix the problem when using process_prior -- it will not be wrapped as a CustomPrior and it will also work with transforms, e.g., for MCMC-based posteriors.

Does this close any currently open issues?

Fixes #790

Copy link
Contributor

@michaeldeistler michaeldeistler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thanks a ton!

@janfb janfb force-pushed the fix-restricted-prior-log-prob branch from 2897ad9 to f7f88af Compare September 3, 2024 14:20
@janfb janfb force-pushed the fix-restricted-prior-log-prob branch from f7f88af to 4226553 Compare September 3, 2024 14:24
@janfb janfb self-assigned this Sep 3, 2024
@janfb janfb added the bug Something isn't working label Sep 3, 2024
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 72.72727% with 6 lines in your changes missing coverage. Please review.

Project coverage is 78.31%. Comparing base (6dec812) to head (4226553).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
sbi/utils/restriction_estimator.py 72.72% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1257      +/-   ##
==========================================
- Coverage   86.05%   78.31%   -7.75%     
==========================================
  Files         118      119       +1     
  Lines        8672     8697      +25     
==========================================
- Hits         7463     6811     -652     
- Misses       1209     1886     +677     
Flag Coverage Δ
unittests 78.31% <72.72%> (-7.75%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
sbi/utils/restriction_estimator.py 76.80% <72.72%> (-8.86%) ⬇️

... and 30 files with indirect coverage changes

@janfb janfb merged commit bd740d6 into main Sep 3, 2024
6 checks passed
@janfb janfb deleted the fix-restricted-prior-log-prob branch September 3, 2024 15:22
janfb added a commit that referenced this pull request Sep 4, 2024
janfb added a commit that referenced this pull request Sep 5, 2024
this bug was introduced in #1257 by removing the lambda fun.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

log_prob fails for Restricted Prior when sampling with SIR
2 participants