-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Increase unittest check_logcdf coverage and fix issues with some distribution methods
#4393
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
Increase unittest check_logcdf coverage and fix issues with some distribution methods
#4393
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4393 +/- ##
==========================================
+ Coverage 88.09% 88.13% +0.03%
==========================================
Files 88 88
Lines 14538 14550 +12
==========================================
+ Hits 12807 12823 +16
+ Misses 1731 1727 -4
|
|
Failing test is irrelevant (flaky random MvNormal issues) |
1223c4e to
02a8619
Compare
AlexAndorra
left a comment
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.
Looks all good, thanks @ricardoV94 ! I'll leave this open 24 hours before merging, in case someone wants to comment 😉
domenzain
left a comment
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.
Hi @ricardoV94,
I've left a couple of comments in a code review for your changes.
The extra hoops for the logic in the original implementation of the logcdf for the HalfNormal distribution were actually about the erfc function for input outside reasonable parameters for the distribution itself.
Best,
Thank you for your review. I disagree with the My solution does not give an unexpected behavior. It gives the same results one gets when inputting invalid parameters/ values in the I do agree with having a more useful comment describing the nature of the issue in the code. I will add it tomorrow! |
…roperly evaluated. Fix issues with `Uniform`, `HalfNormal`, `Gamma`, and `InverseGamma` distributions.
Add more informative comment for Gamma and InverseGamma hack. Update Release note.
02a8619 to
07f09ad
Compare
7308533 to
d0316b5
Compare
|
Last couple of revisions are complete. I updated the first message to highlight everything that this PR does in one place, but here are the new changes:
|
Move new checks to `check_logcdf`.
bd28eb9 to
8c51062
Compare
…viously failing test in 32bit OS)
|
I had to do 2 small changes:
It is ready for review :) |
AlexAndorra
left a comment
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.
All good now, thanks @ricardoV94 🥳
Changes:
This PR proposes two changes to
check_logcdfto:-infand0.TypeErroris returned.This extended test revealed some issues with current implementations of the
logcdfmethod, which are also fixed by this PR:Uniform: Would incorrectly evaluate values aboveupperto-infHalfNormal: Would returnnanfor negative values. It was also unclear to me what the previouslogcdflogic was doing, as it seems to me thattt.lt(z, -1.0)could never evaluate toTruegiven valid positive values andsigma. As such, I simplified the code as well as correcting the invalid logcdf evaluation for negative values. Am I missing something? (pinging @domenzain)Gamma, andInverseGammawere currently failing with invalid parameters due to InverseGamma logcdf method fails with invalid parameters when array is used #4340 and Return NaN in C implementations of SciPy Ops aesara-devs/aesara#224. I added a dirty hack to hide the issue for now. It can be simplified once those issues are solved.BetaandStudentTlogcdf now raises informativeTypeErrorwhen asked to evaluate multiple values (Beta logcdf method fails with array of values #4342)As suggested by @AlexAndorra in #4387 (comment), the docstrings of the logcdf methods were updated to better reflect when multiple values can or cannot be evaluated.
It was necessary to change the test domains of the
FlatandHalfFlatdistributions to their actual domains.This test is also relevant for the current PR #4387, were these same changes were helpful in debugging issues with the implementations of the
logcdfmethods. I thought it was best to have this as a separate PR as that one is quite large already.Finally, I think this does meaningfully increase the overhead of the unit tests since, at most, only three extra logp evaluations are being done for each distribution (one for each finite edge of a domain plus a (2,) array for multiple values).