-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Update pymc.TruncatedNormal docstring #5546
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
Update pymc.TruncatedNormal docstring #5546
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5546 +/- ##
=======================================
Coverage 87.62% 87.62%
=======================================
Files 76 76
Lines 13775 13775
=======================================
Hits 12070 12070
Misses 1705 1705
|
cc @OriolAbril in case youd like to 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.
There are parameters missing. If you look at the dist
method you'll see that tau
, sd
and transform
are also accepted. I am not up to date with v4 so I don't know if maybe some of these are deprecated now (which should also be documented via the decorator) their defaults... Can someone weigh in on both deprecations and defaults?
pymc/distributions/continuous.py
Outdated
upper: float (optional) | ||
Right bound. | ||
lower : tensor_like of float, optional | ||
Left bound. Defaults to 0. |
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 think the defaults are wrong (same for upper). I'd bet the default is no bound or infinity or somehting of the sort
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 am unable to find out the default value for mu and sigma.
could you please guide me, how to identify these dafult value so that it can help me for other methords.
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.
First check the description in the docstring, sometimes the defaults are incorrectly explained in the extended summary section. If they are not you should read the .dist
method and follow the variables defined there and/or function calls to see what the defaults are. Here are some examples, I hope they are illustrative and you can follow the pattern for the rest.
mu
pymc/pymc/distributions/continuous.py
Line 720 in 4223b6e
mu = at.as_tensor_variable(floatX(mu)) |
it is defined straight away here, so it seems like it is not optional actually. @ricardoV94 is this intended? If the value in the function call were 0 instead of None then you would use the default 0
instead of optional for example, however, if some function is called to get the default, it probably means you should use optional and explain the default (or combinations of defaults depending on other parameters) in the description
lower
pymc/pymc/distributions/continuous.py
Line 724 in 4223b6e
lower = at.as_tensor_variable(floatX(lower)) if lower is not None else at.constant(-np.inf) |
the default in the function call is None, and when it is None, what is actually used is - infinity. When a value is given, that value is used. So lower should be lower : tensor_like of float, default -numpy.inf
(and check in the readthedocs preview that it gets rendered correctly).
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 like the default of mu should indeed be zero, not None
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.
transform as a positional argument is outdated an should be removed from the dist
signature
Hi @OriolAbril, could you please verify if the doc for pymc/pymc/distributions/continuous.py Line 549 in 4223b6e
and pymc.TruncatedNormal.logp takes |
default |
maybe it is deprecated? I don't know why there would be two equivalent arguments 🤔 let's see if someone else knows.
Ignore all the methods (in distributions) that are not
Try |
When both sd and sigma are present, sd should not only not be documented but removed completely, in general. Therefore, here sd should be removed and consequently should not be documented |
Hi @OriolAbril, I reoved |
I think the sd has been debated repeatedly and folks didn't want to remove it last time it was brought up |
Seems like people are happy to remove them now. We should probably do it in a separate PR and for all the distributions that have the sigma/sd duplication at once |
I am updating all the docstrings, can I remove |
https://pymc--5546.org.readthedocs.build/en/5546/api/distributions/generated/pymc.TruncatedNormal.html#pymc.TruncatedNormal -numpy.inf is still not rendering properly, what to do ? |
I think it's better to leave that for a separate PR |
Sure, should I undo the removal of sd in this PR or will I avoid it from the next PR? |
Yup |
Sure |
Hi @OriolAbril, it's done now, please have a look |
Related to #5459
This will update the pymc.TruncatedNormal docstring.