-
Notifications
You must be signed in to change notification settings - Fork 246
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
pre-commit hook for docstring format #1944
base: master
Are you sure you want to change the base?
Conversation
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.
Do you know what the max length is?
examples/baseball.py
Outdated
Number of hits has a Binomial distribution with independent | ||
probability of success, $\phi_i$. Each $\phi_i$ follows a Beta | ||
r"""Number of hits has a Binomial distribution with independent probability of success, $\phi_i$. Each $\phi_i$ | ||
follows a Beta. |
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.
the format is wrong - this is "Beta distribution".
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.
Yeah, it seems to be wrong. It also messed with the license which failed the CI.
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.
re license: maybe update those lines: https://github.com/pyro-ppl/numpyro/blob/master/scripts/update_headers.py#L54-L57 ?
if lineno < len(lines) and not lines[lineno].isspace() and not lines[lineno] == '"""\n':
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.
Done in abef925.
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.
It is still failing, my jugaad was to add a comment before the docstring that will create a line between the license header and the docstring.
I have set it to 120 in the |
Could you change it to 88 instead? Currently, we use 88 for ruff https://github.com/pyro-ppl/numpyro/blob/master/pyproject.toml#L34 |
Sure, let me push the updated code! |
Lotka–Volterra equations. Real positive parameters `alpha`, `beta`, `gamma`, `delta` | ||
"""Lotka–Volterra equations. | ||
Real positive parameters `alpha`, `beta`, `gamma`, `delta` |
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.
not sure why this line is shorter than the other ones.
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 formatter takes the first sentence as a summary and the rest of the docstring as an extended summary.
pass | ||
|
||
|
||
class RBFKernel(SteinKernel): | ||
"""Calculates the Gaussian RBF kernel function used in [1]. The kernel is given by | ||
"""Calculates the Gaussian RBF kernel function used in [1]. The kernel is given | ||
by. |
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.
no dot
at the end here I think. Maybe move The kernel is given by
to a new paragraph.
@@ -119,7 +116,7 @@ def mode(self): | |||
|
|||
|
|||
class IMQKernel(SteinKernel): | |||
"""Calculates the IMQ kernel from Theorem 8 of [1]. The kernel is given by | |||
"""Calculates the IMQ kernel from Theorem 8 of [1]. The kernel is given by. |
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.
same for here
@@ -161,8 +158,7 @@ def kernel(x, y): | |||
|
|||
|
|||
class LinearKernel(SteinKernel): | |||
""" | |||
Calculates the linear kernel from Theorem 3.3 in [1]. The kernel is given by | |||
"""Calculates the linear kernel from Theorem 3.3 in [1]. The kernel is given by. |
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.
like above
@@ -191,7 +187,8 @@ def kernel(x, y): | |||
|
|||
|
|||
class RandomFeatureKernel(SteinKernel): | |||
"""Calculates the Gaussian variate of random kernel in eq. 5 and 6 of [1]. The kernel is given by | |||
"""Calculates the Gaussian variate of random kernel in eq. 5 and 6 of [1]. The | |||
kernel is given by. |
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.
like above
|
||
[1] https://en.wikipedia.org/wiki/Matrix_normal_distribution | ||
:param array_like scale_tril_column: Lower cholesky of columns correlation | ||
matrix. **References** [1] |
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.
reference should be in a separate paragraph
[1] https://github.com/pymc-devs/pymc/blob/244fb97b01ad0f3dadf5c3837b65839e2a59a0e8/pymc/distributions/transforms.py#L266 | ||
[2] https://www.pymc.io/projects/docs/en/stable/api/distributions/generated/pymc.ZeroSumNormal.html | ||
[3] https://learnbayesstats.com/episode/74-optimizing-nuts-developing-zerosumnormal-distribution-adrian-seyboldt/ | ||
**References** [1] https://github.com/pymc-devs/pymc/blob/244fb97b01ad0f3dad |
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.
reference should be in a separate paragraph
|
||
*** References *** [1] Luc Devroye "Non-Uniform Random Variate Generation", |
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.
reference should be in a separate paragraph
**References:** | ||
|
||
[1] On Markov chain Monte Carlo Methods For Tall Data | ||
**References:** [1] On Markov chain Monte Carlo Methods For Tall Data |
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.
reference should be in a separate paragraph
This `Differential evolution proposal | ||
<http://www.stat.columbia.edu/~gelman/stuff_for_blog/cajo.pdf>`_ is | ||
implemented following `Nelson et al. (2013) | ||
"""A proposal using differential evolution.\n\nThis |
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.
would \n\n
be the right thing here?
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.
If you run the pre-commit multiple times in a row, the docformatter pushes the line starting with "is" one space to the right each time, causing the pre-commit to fail. This is due to the max length we have set. I found this trick to reproduce the same docstring while rendering.
This hook will format the docstrings. See PyCQA/docformatter#265 for multiline docstring format.