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

Minor fix for EnsemblePosterior weights.setter #1299

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

CompiledAtBirth
Copy link
Contributor

@CompiledAtBirth CompiledAtBirth commented Oct 21, 2024

What does this implement/fix? Explain your changes

In sbi.inference.posteriors, the EnsemblePosterior instantiation would return a TypeError when passing weights (torch.Tensor or List[float]). The condition elif weights is Tensor or weights is List would always return False, I changed the condition to elif isinstance(weights, Tensor) or isinstance(weights, List), where Tensor is the torch class of the same name.

Does this close any currently open issues?

No, to the best of my knowledge.

Any relevant code examples, logs, error output, etc?

The only "fix" is intended to properly test the type of the weights attribute of EnsemblePosterior in case it is not None.

Any other comments?

I do not know whether I should have opened an new issue instead of doing a minor one-line PR. I will leave empty most of the Checklist items below.
...

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask. We're here to
help! This is simply a reminder of what we are going to look for before merging
your code.

  • [ x] I have read and understood the contribution
    guidelines
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have reported how long the new tests run and potentially marked them
    with pytest.mark.slow.
  • New and existing unit tests pass locally with my changes
  • I performed linting and formatting as described in the contribution
    guidelines
  • [ x] There are no conflicts with the main branch

For the reviewer:

  • I have reviewed every file
  • All comments have been addressed.

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.43%. Comparing base (3d5cb24) to head (e535aca).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
sbi/inference/posteriors/ensemble_posterior.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1299       +/-   ##
===========================================
- Coverage   89.30%   78.43%   -10.87%     
===========================================
  Files         119      119               
  Lines        8721     8732       +11     
===========================================
- Hits         7788     6849      -939     
- Misses        933     1883      +950     
Flag Coverage Δ
unittests 78.43% <0.00%> (-10.87%) ⬇️

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

Files with missing lines Coverage Δ
sbi/inference/posteriors/ensemble_posterior.py 50.00% <0.00%> (-37.97%) ⬇️

... and 31 files with indirect coverage changes

Copy link
Contributor

@janfb janfb left a comment

Choose a reason for hiding this comment

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

this looks good. thanks for fixing this!

The linter action is failing because your proposed change can be simplified. I made a suggestion.

To proceed, please accept it to make sure the linter and the tests actions run through. Thanks

sbi/inference/posteriors/ensemble_posterior.py Outdated Show resolved Hide resolved
Copy link
Contributor

@janfb janfb left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for fixing this! :problem

@janfb janfb merged commit 653d0b4 into sbi-dev:main Nov 12, 2024
5 of 6 checks passed
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.

2 participants