Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update discussion of parameter type specifications in docstrings #1757

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 21 commits into from
Dec 16, 2022

Conversation

namurphy
Copy link
Member

@namurphy namurphy commented Oct 8, 2022

This PR expands the discussion on type lines in docstrings, since it didn't have enough information before. I'm planning to base a lot of it on the matplotlib doc guide and on numpy/numpydoc#367. In particular, I want to add a bunch of type line examples, including for infrequent cases.

@github-actions
Copy link

github-actions bot commented Oct 8, 2022

Thank you for contributing to PlasmaPy! The project's future depends deeply on contributors like you, so we deeply appreciate it! 🌱 The following checklist will be used by the code reviewer to help guide the code review process.

  • Overall
    • Does the PR do what it intends to do?
    • Except for very minor changes, is a changelog entry included and consistent with the changelog guide?
    • Are the continuous integration checks passing? (Most linter problems can be automagically fixed by commenting on this PR with pre-commit.ci autofix.)
  • Code
    • Is new/updated code understandable and consistent with the coding guide?
    • Are there ways to greatly simplify the implementation?
    • Are there any large functions that should be split up into shorter functions?
  • Tests
    • Are tests added/updated as required, and consistent with the testing guide?
    • Are the tests understandable?
    • Do the tests cover all important cases?
  • Docs
    • Are docs added/updated as required, and consistent with the doc guide?
    • Are the docs understandable?
    • Do the docs show up correctly in the preview, including Jupyter notebooks?

@codecov
Copy link

codecov bot commented Oct 8, 2022

Codecov Report

Base: 98.33% // Head: 98.33% // No change to project coverage 👍

Coverage data is based on head (754450c) compared to base (528e962).
Patch has no changes to coverable lines.

❗ Current head 754450c differs from pull request most recent head a5452e4. Consider uploading reports for the commit a5452e4 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1757   +/-   ##
=======================================
  Coverage   98.33%   98.33%           
=======================================
  Files          95       95           
  Lines        8343     8343           
=======================================
  Hits         8204     8204           
  Misses        139      139           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@namurphy namurphy added this to the 0.9.0 milestone Oct 27, 2022
@namurphy
Copy link
Member Author

namurphy commented Dec 6, 2022

My motivation for doing this is related to #1270 and #1271, in particular since if we standardize the type lines then we can eventually do cool stuff like linking, etc.

@namurphy
Copy link
Member Author

namurphy commented Dec 6, 2022

It looks like there isn't a standard practice for multi-line type specifications: numpy/numpydoc#87

@namurphy
Copy link
Member Author

namurphy commented Dec 6, 2022

Oh, the LSST docstring guide has a section on docstring parameter types, with some examples pretty much from numpydoc. There are similarities and differences with matplotlib's conventions.

@namurphy namurphy marked this pull request as ready for review December 15, 2022 16:14
@namurphy namurphy requested a review from a team as a code owner December 15, 2022 16:14
@namurphy namurphy requested review from StanczakDominik and removed request for a team December 15, 2022 16:14
@namurphy
Copy link
Member Author

namurphy commented Dec 15, 2022

A lot of my motivation for this PR is that the numpydoc standard doesn't cover a bunch of edge cases that come up for packages that depend on NumPy pretty often, but seemingly don't come up for NumPy itself. I am trying to be consistent with primarily the matplotlib style guide and also the LSST standards.

The numpydoc standard would have been a much better place to clear up edge cases, but it seems pretty difficult to change since the PR I submitted on keyword-only and positional-only has been waiting on validation functionality to be added.

My main motivations for this PR are that standardizing the type specifications (ideally across projects) will:

  • Make documentation easier to read because of improved consistency 😺 😺 😺 😺
  • Make docstrings more concise and less DRY by using links to glossary terms for things like particle-like and array-like
  • Set the stage for docstring autoformatters

@namurphy
Copy link
Member Author

@pheuer — might you be availble to review this? I was thinking you might have insight into parameter type description edge cases that are likely to come up in plasmapy.diagnostics, and possibly notice things that are missing. Thank you!

Copy link
Member

@StanczakDominik StanczakDominik left a comment

Choose a reason for hiding this comment

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

To me, it looks okay. Having taken a look at your numpydoc PRs, the only worry I have is extending our docs too much beyond what the numpydoc standard currently offers. I don't want to break tooling that's based on a strict (as in, validated) interpretation of the standard.

But that's probably a worry for another day.

I also wonder how this plays with xarray, which I'd like to integrate in one day. Then you don't need to track the dimension number or ordering of your array because you're operating on named dimensions anyway.

But that's also a worry for another day.

@namurphy
Copy link
Member Author

Having taken a look at your numpydoc PRs, the only worry I have is extending our docs too much beyond what the numpydoc standard currently offers. I don't want to break tooling that's based on a strict (as in, validated) interpretation of the standard.

Agreed. Going with matplotlib's style guide when possible partially addresses that worry, but not completely.

At the moment our docstrings go beyond what's in the numpydoc standard in a bunch of places. For example, a lot of what's in nitpick_ignore_regex is in there for the parameter type specifications for the nitpicky doc builds. Consistentifying docstring practices will mean we can simplify what's in nitpick_ignore_regex too.

I also wonder how this plays with xarray

Interesting! I looked at xarray's contributor guide and didn't see much about docstrings.

But that's also a worry for another day.

That is absolutely my favorite type of worry! 😹

Copy link
Member

@pheuer pheuer left a comment

Choose a reason for hiding this comment

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

All looks good - I think examples are really helpful for this but you've included a good number of them (and more are obviously in the code...)


.. todo::

Add a convention for multi-line type specifications.
Copy link
Member

Choose a reason for hiding this comment

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

This would be great...

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed! I tried out some options, but have yet to find one that Sphinx renders as intended into the online documentation. Sigh!

@namurphy namurphy changed the title Update discussion of type lines for parameters in docstrings Update discussion of parameter type specifications in docstrings Dec 16, 2022
@namurphy namurphy enabled auto-merge (squash) December 16, 2022 02:01
@namurphy namurphy merged commit e12d9f7 into PlasmaPy:main Dec 16, 2022
@namurphy namurphy deleted the docstring-guide-type-line branch December 21, 2022 17:07
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.

3 participants