-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Modify compare() docstring, error-check, pass var_name. #1616
Conversation
Looking at the test failures, it seems that sometimes ArviZ computes the |
Maybe the test helpers have not been updated and still have |
I tried the error-catching and re-raising approach and it worked locally for me, so I am pushing it for inspection and testing. I still need to add some new tests to verify that the errors are signaled as I expect. |
Check to see if the log_likelihood groups have more than one data variable, and if so, require the var_name parameter. This avoids having a less understandable error message crop up later. Introduce `var_name` parameter, and pass it through to the IC function invoked by compare.
Previously, if we got a TypeError when trying to find a log_likelihood in from_pymc3() that TypeError would be squashed completely. Now we will echo it to the log before handling it.
Took @OriolAbril correction.
Catch errors from IC functions invoked inside compare and annotate them with information about the source `InferenceData` object.
@OriolAbril I think this now does things the way you wanted: I grab up the errors and signal a new error |
Many examples show this as a good variable name for exceptions, particularly in "except <ExceptionClass> as e:"
Codecov Report
@@ Coverage Diff @@
## main #1616 +/- ##
==========================================
- Coverage 90.91% 90.89% -0.03%
==========================================
Files 108 108
Lines 11671 11700 +29
==========================================
+ Hits 10611 10635 +24
- Misses 1060 1065 +5
Continue to review full report at Codecov.
|
Make sure we check for multiple observed variables in compare() and that support for "var_name" works.
Previously, we checked for `sample_stats` in `get_log_likelihood()` *before* reading `log_likelihood`. Add a check that `log_likelihood` must be missing before we check `sample_stats`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a couple minor comments, looks good
* Limit recomputation in tests by scoping a fixture. * Test for expected IC in `compare` test. * Refine type assertion.
@OriolAbril If my changes meet with your approval, please squash and merge. |
) * Modify compare() docstring, and var_name param and error-check. Check to see if the log_likelihood groups have more than one data variable, and if so, require the var_name parameter. This avoids having a less understandable error message crop up later. Introduce `var_name` parameter, and pass it through to the IC function invoked by compare. * Fix error in argument test. * More explicit error message. Previously, if we got a TypeError when trying to find a log_likelihood in from_pymc3() that TypeError would be squashed completely. Now we will echo it to the log before handling it. * Fix type signature of compare(). Took @OriolAbril correction. * Annotated IC function errors from compare(). Catch errors from IC functions invoked inside compare and annotate them with information about the source `InferenceData` object. * Remove incorrect docstring. * pylint * mypy fixes. * Make "e" acceptable variable name. Many examples show this as a good variable name for exceptions, particularly in "except <ExceptionClass> as e:" * Changelog update. * Backward-compatibility fix. * Fix test. Error now caught sooner. * Fix mypy issues. * Python 3.5 and 3.6 compatibility. * Whitespace issue caught by Oriol. * Test for error-trapping. Make sure we check for multiple observed variables in compare() and that support for "var_name" works. * Don't let sample_stats shadow log_likelihood. Previously, we checked for `sample_stats` in `get_log_likelihood()` *before* reading `log_likelihood`. Add a check that `log_likelihood` must be missing before we check `sample_stats`. * Improvements suggested by OriolAbril. * Limit recomputation in tests by scoping a fixture. * Test for expected IC in `compare` test. * Refine type assertion.
Description
Check to see if the log_likelihood groups have more than one data
variable, and if so, require the var_name parameter. This avoids
having a less understandable error message crop up later.
Introduce
var_name
parameter tocompare()
, and pass it through to subsidiary IC function. @OriolAbril reports it was simply an oversight that this wasn't done before.Addresses issue #1614
Checklist