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

Some clean up of contexts #711

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

torfjelde
Copy link
Member

Some cleanup of the context implementations:

  1. Fixes bug in PrefixContext which doesn't actually work for .~ statements due to implementing the incorrect signature.
  2. Removes now-unusued implementations of tilde_*_assume/observe methods for PriorContext and LikelihoodContext + removed their vars field which is also not used any more (this was only used by the logprob macro which was removed in Remove the prob and logprob macros #604 )

@coveralls
Copy link

coveralls commented Nov 1, 2024

Pull Request Test Coverage Report for Build 11707808796

Details

  • 29 of 29 (100.0%) changed or added relevant lines in 4 files are covered.
  • 17 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+1.5%) to 83.895%

Files with Coverage Reduction New Missed Lines %
src/model.jl 3 90.32%
src/threadsafe.jl 14 48.6%
Totals Coverage Status
Change from base Build 11707211020: 1.5%
Covered Lines: 3485
Relevant Lines: 4154

💛 - Coveralls

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.65%. Comparing base (abb2ed4) to head (23bc877).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #711      +/-   ##
==========================================
+ Coverage   82.14%   83.65%   +1.51%     
==========================================
  Files          30       30              
  Lines        4200     4166      -34     
==========================================
+ Hits         3450     3485      +35     
+ Misses        750      681      -69     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@penelopeysm penelopeysm left a comment

Choose a reason for hiding this comment

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

LGTM as remaining CI errors are known to be due to #702

@torfjelde
Copy link
Member Author

Thanks @penelopeysm !

Fixes bug in PrefixContext which doesn't actually work for .~ statements due to implementing the incorrect signature.

I think we need a way to test this though (as that would have caught the current bug). IMO every context should at be evaluated with both DefaultContext and SamplingContext to ensure that the full tilde-pipeline is implemented.

@torfjelde
Copy link
Member Author

torfjelde commented Nov 5, 2024

Think this PR is ready for another round of reviews 👍 Added proper testing for the contexts + a test_context function to streamline the testing of a new context a bit more. Also fixed quite a few bugs in the process 😬

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@torfjelde torfjelde self-assigned this Nov 5, 2024
Copy link
Member

@penelopeysm penelopeysm left a comment

Choose a reason for hiding this comment

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

Still looks good, save for one question!

Comment on lines -132 to -147
@testset "setchildcontext" begin
@testset "nested contexts" begin
# Both of the following should result in the same context.
context1 = ParentContext(ParentContext(ParentContext()))
context2 = setchildcontext(
ParentContext(), setchildcontext(ParentContext(), ParentContext())
)
@test context1 === context2
end

@testset "$context" for context in parent_contexts
# Setting the child context to a leaf should now change the `leafcontext` accordingly.
new_leaf =
leafcontext(context) isa DefaultContext ? PriorContext() : DefaultContext()
new_context = setchildcontext(context, new_leaf)
@test childcontext(new_context) === leafcontext(new_context) === new_leaf
Copy link
Member

Choose a reason for hiding this comment

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

Did these tests get cut for a reason? As I don't see corresponding ones in the new test_context.

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.

3 participants