Skip to content

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

Merged
merged 7 commits into from
Mar 12, 2022

Conversation

purna135
Copy link
Member

@purna135 purna135 commented Mar 4, 2022

Related to #5459

This will update the pymc.TruncatedNormal docstring.

@codecov
Copy link

codecov bot commented Mar 4, 2022

Codecov Report

Merging #5546 (fbf1190) into main (5eaa516) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5546   +/-   ##
=======================================
  Coverage   87.62%   87.62%           
=======================================
  Files          76       76           
  Lines       13775    13775           
=======================================
  Hits        12070    12070           
  Misses       1705     1705           
Impacted Files Coverage Δ
pymc/distributions/continuous.py 97.23% <ø> (ø)

@canyon289
Copy link
Member

cc @OriolAbril in case youd like to review

Copy link
Member

@OriolAbril OriolAbril left a 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?

upper: float (optional)
Right bound.
lower : tensor_like of float, optional
Left bound. Defaults to 0.
Copy link
Member

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

Copy link
Member Author

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.

Copy link
Member

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

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

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).

Copy link
Member

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

Copy link
Member

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

@purna135
Copy link
Member Author

purna135 commented Mar 6, 2022

Hi @OriolAbril, could you please verify if the doc for sigma and tau is correct.
also I noticed there is no description for sd in pymc.Normal

def dist(cls, mu=0, sigma=None, tau=None, sd=None, no_assert=False, **kwargs):

and pymc.TruncatedNormal.logp takes mu, sigma, lower, upper as parameter but these are not mentioned in parameter list, should we add these parameter also?

image

@purna135
Copy link
Member Author

purna135 commented Mar 6, 2022

default -numpy.inf is not rendering properly should we use numpy.NINF ?

@OriolAbril
Copy link
Member

also I noticed there is no description for sd in pymc.Normal

maybe it is deprecated? I don't know why there would be two equivalent arguments 🤔 let's see if someone else knows.

pymc.TruncatedNormal.logp takes mu, sigma, lower, upper as parameter but these are not mentioned in parameter list, should we add these parameter also?

Ignore all the methods (in distributions) that are not .dist. They should not be used directly, there is no need to document them. We are looking into removing them from the docs, but it's a bit tricky.

default -numpy.inf is not rendering properly should we use numpy.NINF ?

Try - numpy.inf, maybe the space fixes the rendering. The uppercase feels a bit strange personally, kind of breaks the symmetry.

@OriolAbril
Copy link
Member

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

@purna135
Copy link
Member Author

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 sd completly, please have a look if this is the right way to do so.

@ricardoV94
Copy link
Member

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

I think the sd has been debated repeatedly and folks didn't want to remove it last time it was brought up

@ricardoV94
Copy link
Member

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

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

@purna135
Copy link
Member Author

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 sd in this PR only ?

@purna135
Copy link
Member Author

@ricardoV94
Copy link
Member

I am updating all the docstrings, can I remove sd in this PR only ?

I think it's better to leave that for a separate PR

@purna135
Copy link
Member Author

Sure, should I undo the removal of sd in this PR or will I avoid it from the next PR?

@ricardoV94
Copy link
Member

Sure, should I undo the removal of sd in this PR or will I avoid it from the next PR?

Yup

@ricardoV94 ricardoV94 changed the title Update pymc.TruncatedNormal docsting Update pymc.TruncatedNormal docstring Mar 11, 2022
@OriolAbril
Copy link
Member

@purna135 can you undo the sd change here so all sd arguments are removed in #5583? We'll then merge the PR

@purna135
Copy link
Member Author

Sure

@purna135
Copy link
Member Author

Hi @OriolAbril, it's done now, please have a look

@OriolAbril OriolAbril merged commit 7f434bb into pymc-devs:main Mar 12, 2022
@purna135 purna135 deleted the doc_continuous_TruncatedNormal branch March 12, 2022 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants