Skip to content

refactor sbc funcs and tests #1578

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

refactor sbc funcs and tests #1578

wants to merge 2 commits into from

Conversation

janfb
Copy link
Contributor

@janfb janfb commented Apr 24, 2025

  • Refactored the SBC module for better code organization and API clarity.
  • Moved VIPosterior handling to the public API with a wrapper approach.
  • Added helper functions for better maintainability.
  • Enhanced tests with fixtures, dedicated test cases for parallelization and batch sampling, and improved assertions.
  • All changes maintain backward compatibility.

Copy link

codecov bot commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 86.11111% with 5 lines in your changes missing coverage. Please review.

Project coverage is 78.89%. Comparing base (3e845bd) to head (b5f3e2d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
sbi/diagnostics/sbc.py 86.11% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1578      +/-   ##
==========================================
- Coverage   86.02%   78.89%   -7.13%     
==========================================
  Files         135      135              
  Lines       10754    10770      +16     
==========================================
- Hits         9251     8497     -754     
- Misses       1503     2273     +770     
Flag Coverage Δ
unittests 78.89% <86.11%> (-7.13%) ⬇️

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

Files with missing lines Coverage Δ
sbi/diagnostics/sbc.py 88.50% <86.11%> (-4.46%) ⬇️

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

str,
Callable[[Tensor, Tensor], Tensor],
List[Callable[[Tensor, Tensor], Tensor]],
] = "marginals",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we always call it with reduce_fn(theta, x)

def _run_sbc(
thetas: Tensor,
xs: Tensor,
posterior_samples: Tensor,
posterior: NeuralPosterior,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we used this argument only to check whether it's a VIPosterior. we now do this above in run_sbc so that this internal function can be called with just samples.

@janfb janfb requested a review from michaeldeistler April 24, 2025 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant