Skip to content
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

document default values as part of the type spec #289

Merged
merged 3 commits into from
Jan 9, 2021

Conversation

keewis
Copy link
Contributor

@keewis keewis commented Jul 29, 2020

Not sure if there is a better way to state that the colon is a matter of taste and has no effect on the generated documentation.

@codecov-commenter
Copy link

Codecov Report

Merging #289 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master     #289   +/-   ##
=======================================
  Coverage   93.10%   93.10%           
=======================================
  Files           7        7           
  Lines        1261     1261           
=======================================
  Hits         1174     1174           
  Misses         87       87           

Copy link
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think then we need some advice on when "optional" is preferred over a default value. For me, "optional" should be used where the meaning of the default value would not be clear if written in place. For example None is often used as a placeholder for "disable some functionality" or "determine automatically", and this is better off described below the type spec.

We have adopted default= rather than default: in Scikit-learn. See https://scikit-learn.org/dev/developers/contributing.html#guidelines-for-writing-documentation

doc/format.rst Outdated Show resolved Hide resolved
@keewis
Copy link
Contributor Author

keewis commented Jul 30, 2020

I think then we need some advice on when "optional" is preferred over a default value

sure, I'll try to add that.

We have adopted default= rather than default: in Scikit-learn

Ugh. Yes, I only ever looked at pandas and xarray when suggesting those. I imagine there are lots of projects with other formats, e.g. int (default None). Should we allow all of those, or would it be better to list a few options and discourage everything else (which might be easier to support)?

@jnothman
Copy link
Member

jnothman commented Jul 30, 2020 via email

@keewis
Copy link
Contributor Author

keewis commented Aug 1, 2020

I guess for now we could pick the three already mentioned (default , default: , and default=) and state that there might be more?

@jnothman
Copy link
Member

jnothman commented Aug 1, 2020

I'd rather just display one that seems clear as an example.

@keewis
Copy link
Contributor Author

keewis commented Aug 5, 2020

the issue with that is that with just a single example we'd have to describe how other notations are allowed to be different, which would deviate from the current style of the guide.

For my original suggestion, how about:

or as part of the type, instead of ``optional``. If the default value would not be
used as a value, ``optional`` is preferred. These are all equivalent::

    copy : bool, default True
    copy : bool, default=True
    copy : bool, default: True

Co-authored-by: Joel Nothman <joel.nothman@gmail.com>
@rgommers
Copy link
Member

rgommers commented Jan 1, 2021

For my original suggestion, how about:

That makes sense to me. I propose to do that given that that's the state we're in today, and it's better than not merging this PR.

@keewis
Copy link
Contributor Author

keewis commented Jan 6, 2021

done. @rgommers, was that what you were thinking of?

@rgommers rgommers merged commit af154f4 into numpy:master Jan 9, 2021
@rgommers
Copy link
Member

rgommers commented Jan 9, 2021

Indeed, thanks @keewis, merged. Thanks @jnothman for reviewing too.

@rgommers rgommers added this to the 1.2.0 milestone Jan 9, 2021
@keewis keewis deleted the default-values branch January 9, 2021 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

syntax to document default values
5 participants