-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
changed default values for TruncatedNormal lower and upper from None to -np.inf… #3250
Conversation
@gilliss Thanks, can you add a test? |
@twiecki, I'm not familiar with how the |
@gilliss Apparently we didn't test sampling from the TruncatedNormal if either bound was not supplied. Such a test should break before this PR but pass now. Thus I would add a test specifically for that case. |
@twiecki, I've updated the PR with a specific test tacked onto the bottom of test_distributions_random.py. |
Best to follow the existing logic, so you could just duplicate https://github.com/pymc-devs/pymc3/blob/893414fdbada86a9741553563ab725028864e319/pymc3/tests/test_distributions_random.py#L220 and remove one of the two bounds and then add another method here: https://github.com/pymc-devs/pymc3/blob/893414fdbada86a9741553563ab725028864e319/pymc3/tests/test_distributions_random.py#L429 |
…p.isfinite error in distribution.Distribution
…ince pymc3_random sets paramdomains points anyway
Thanks for your help, @twiecki.
|
@gilliss Pretty good motivation for why tests are a good idea :). Travis seems unhappy but I don't think it's related to this. |
@twiecki, another pass. |
I think we need to fix these too: https://github.com/pymc-devs/pymc3/pull/3250/files#diff-1837763aea633f0d6324583c00051d83R647 Not sure why the tests wouldn't have caught that, can you look into what the current test actually tests, if not the logp? |
It's the �[1m> assert_almost_equal(logp(pt), logp_reference(pt), decimal=decimal, err_msg=str(pt))�[0m
�[1m�[31mE AssertionError: �[0m
�[1m�[31mE Arrays are not almost equal to 6 decimals�[0m
�[1m�[31mE {'mu': array(2.1), 'sd': array(0.99), 'lower': array(-1.5), 'upper': array(0.9), 'value': array(-1.)}�[0m
�[1m�[31mE (mismatch 100.0%)�[0m
�[1m�[31mE x: array(-5.811449)�[0m
�[1m�[31mE y: array(-3.627489)�[0m
�[1m�[31mpymc3/tests/test_distributions.py�[0m:448: AssertionError It looks like this particular test had set the lower and upper params, so it's not a default params issue. I'll try changing the None checks to inf checks in |
I think we might be setting limits for the scipy distribution, but not the other one. Also, can you rebase from master? |
I think your current one just tests the overall behavior of the RV (shape etc). More critical would be a test identical to https://github.com/pymc-devs/pymc3/blob/e9d892ceda642cb09c7772bc776c5388a0ce370d/pymc3/tests/test_distributions_random.py#L437. |
It seems like a variety of upper and lower settings are already tested by def test_truncated_normal_lower(self):
def ref_rand(size, mu, sd, lower, upper):
return st.truncnorm.rvs((lower-mu)/sd, (np.inf-mu)/sd, size=size, loc=mu, scale=sd)
pymc3_random(pm.TruncatedNormal, {'mu': R, 'sd': Rplusbig, 'lower':-Rplusbig},
ref_rand=ref_rand) where the upper has been forced to np.inf? |
Yes, exactly. You can probably just set |
@gilliss Are you still working on this? Seems like there are test-failures:
|
@twiecki Thanks for checking in. I just made another push, 2cd14ab. For this push, I merged the latest from In summary this pr adds the members |
@junpenglao Sorry, I don't consider so much. I appreciate what he has done. I will consider that in the future |
Alright, this looks good. See minor syntax fixes and it also needs a line in the release-notes (at the end of maintenance). |
minor syntax Co-Authored-By: gilliss <[email protected]>
minor syntax Co-Authored-By: gilliss <[email protected]>
minor syntax Co-Authored-By: gilliss <[email protected]>
minor syntax Co-Authored-By: gilliss <[email protected]>
@twiecki I've made the syntax adjustments. For release-notes, do I commit a new line in In any case, the line could say "Set default |
Yes, that sounds great. You can also give add the issue number in that line.. |
Wait, aren't we putting all of the release notes in |
Oh that's right.
…On Tue, Mar 26, 2019 at 5:46 PM Luciano Paz ***@***.***> wrote:
Wait, aren't we putting all of the release notes in RELEASE-NOTES.md at
the root directory of the repo? What's that other release notes file in the
docs?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3250 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AApJmDEvJh50egUh7ogDk2k5WNOAPCNVks5vak7XgaJpZM4YcFqm>
.
|
OK, I'll undo my last and put the line in |
Thanks @gilliss! |
Addressing issue #3248.
Changed default values for
pm.distributions.continuous.TruncatedNormal
lower and upper from None and None to -np.inf and np.inf.This avoids
ValueError: Unexpected type in draw_value: <class 'NoneType'>
, which had appeared upon calls of