Skip to content

DOC Record the default value of parameters #12111

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

Closed
qinhanmin2014 opened this issue Sep 19, 2018 · 7 comments
Closed

DOC Record the default value of parameters #12111

qinhanmin2014 opened this issue Sep 19, 2018 · 7 comments
Labels
Documentation good first issue Easy with clear instructions to resolve help wanted

Comments

@qinhanmin2014
Copy link
Member

In some functions / classes, we fail to record the default value of some parameter (See e.g., DBSCAN.)
Related PR: #12108

@qinhanmin2014 qinhanmin2014 added Documentation good first issue Easy with clear instructions to resolve help wanted labels Sep 19, 2018
@adrinjalali
Copy link
Member

adrinjalali commented Sep 19, 2018

It's worth mentioning, for the contributors, to know that we prefer to follow some suggestions given in numpy's conventions on parameters: https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard (section 4. Parameters). In particular, we prefer to have the default values mentioned in the docstring.

Examples:

max_features : int or float, optional (default=1.0)

algorithm : {‘ball_tree’, ‘kd_tree’, ‘brute’, ‘auto’}, optional
    Algorithm used to compute the nearest neighbors:
        - ‘ball_tree’ will use BallTree (default)
        - ‘kd_tree’ will use KDTree
        - ‘brute’ will use a brute-force search.
        - ‘auto’ will attempt to decide the most appropriate algorithm based on the values passed to fit method.

The default values can be taken in most cases from the function definition or the __init__ of the classes. There are exceptions such as when the parameter is set as warn, in which case the actual default value needs to be found in the code, if not present in the documentation.

Priority is with the cases where the default value is not mentioned. I guess the ones which don't follow the format can be left alone for now. However, should we say, if the docstring of a class is touched for this PR, all parameters should follow the convention?

@qinhanmin2014
Copy link
Member Author

AFAIK, we fail to follow the recommendation from numpy strictly when recording the default value. I doubt whether it's worthwhile to correct these formatting issue. I'm fine as long as the default value is added to the docstring.

@albertcthomas
Copy link
Contributor

It's worth mentioning, for the contributors, to know that we prefer to follow numpy's conventions on parameters: https://numpydoc.readthedocs.io/en/latest/format.html#docstring-standard (section 4. Parameters)

However, section 4 says "Optional keyword parameters have default values, which are displayed as part of the function signature. They can also be detailed in the description".

Hence as along as the default value is in the signature, numpydoc standards do not force to put the default value in the docstring.

@adrinjalali
Copy link
Member

Fair enough, but I guess we still prefer to have the default values mentioned in the docstring. I'll update the post accordingly.

@albertcthomas
Copy link
Contributor

Then we should also mention it in the coding guidelines of the doc contributing section

@qinhanmin2014
Copy link
Member Author

However, section 4 says "Optional keyword parameters have default values, which are displayed as part of the function signature. They can also be detailed in the description".

Thanks @albertcthomas . I guess I'll close this one and let's focus on other important issues. At the same time, I won't reject PRs which improves the doc or the contributing guide.

@jnothman
Copy link
Member

jnothman commented Sep 19, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation good first issue Easy with clear instructions to resolve help wanted
Projects
None yet
Development

No branches or pull requests

4 participants