-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
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
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 😉
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 :) |
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_logcdf
to:-inf
and0
.TypeError
is returned.This extended test revealed some issues with current implementations of the
logcdf
method, which are also fixed by this PR:Uniform
: Would incorrectly evaluate values aboveupper
to-inf
HalfNormal
: Would returnnan
for negative values. It was also unclear to me what the previouslogcdf
logic was doing, as it seems to me thattt.lt(z, -1.0)
could never evaluate toTrue
given 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
, andInverseGamma
were 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.Beta
andStudentT
logcdf now raises informativeTypeError
when 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
Flat
andHalfFlat
distributions 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
logcdf
methods. 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).