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

catch Stan log_prob exceptions inside moment matching #262

Merged
merged 2 commits into from
Mar 20, 2024

Conversation

avehtari
Copy link
Collaborator

Fixes #261

When doing moment matching steps, catch the errors when evaluating log_prob, and break out without an error. This will allow getting moment matching results for all the non-failing observations and may get some moment matching also for the failing ones.

@avehtari avehtari requested a review from jgabry March 19, 2024 19:09
Copy link
Member

@jgabry jgabry left a comment

Choose a reason for hiding this comment

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

This seems like a good idea. I made a few small suggestions in review comments.

R/loo_moment_matching.R Outdated Show resolved Hide resolved
R/loo_moment_matching.R Outdated Show resolved Hide resolved
R/loo_moment_matching.R Outdated Show resolved Hide resolved
R/loo_moment_matching.R Outdated Show resolved Hide resolved
@avehtari
Copy link
Collaborator Author

Thanks for fixes! I need to remember to run tests in fresh R session. I was learning try and TryCatch and for a moment thought I might need the latter, and for some reason didn't see that it was still there

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 66.66667% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 92.68%. Comparing base (52bc270) to head (f2ea5d4).

❗ Current head f2ea5d4 differs from pull request most recent head 36ffa4d. Consider uploading reports for the commit 36ffa4d to get more accurate results

Files Patch % Lines
R/loo_moment_matching.R 66.66% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #262      +/-   ##
==========================================
- Coverage   92.77%   92.68%   -0.10%     
==========================================
  Files          31       31              
  Lines        2836     2842       +6     
==========================================
+ Hits         2631     2634       +3     
- Misses        205      208       +3     

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

@jgabry jgabry merged commit 1ccfc44 into master Mar 20, 2024
6 checks passed
@jgabry jgabry deleted the moment-matching-catch-stan-exceptions branch March 20, 2024 17:42
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.

Stan log_prob exceptions cause moment_matching to fail
3 participants