question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Apply numpydoc validation to docstrings

See original GitHub issue

It would be useful to enforce docstrings style with numpydoc. Currently only a small fraction of docstring pass that validation.

To improve docstring see steps below,

  1. Install scikit-learn from sources (see contribution guide).

  2. install numpydoc master with,

    pip install https://github.com/numpy/numpydoc/archive/master.zip
    
  3. Run the docstring validation on all docstrings,

    pytest maint_tools/test_docstrings.py -v
    

    and choose an estimator with an XFAIL status (meaning that it is a known failure). Write down all of its methods.

  4. Run,

    python maint_tools/test_docstrings.py import_path
    

    to see the list of validation errors for a particular method, where import_path can be for instance sklearn.linear_model.LogisticRegression (for the main estimator docstring) or sklearn.linear_model.LogisticRegression.fit (for the docstring of the fit method).

  5. Fix the docstring until validation passes. Repeat on all public methods of the chosen estimator.

  6. Add the estimator to the whitelist in maint_tools/test_docstrings.py here. Note that this list accepts regular expressions, so LogisticRegression will match all methods of that estimator, and also potentially other estimators e.g. LogisticRegressionCV. For instance one can use LogisticRegression$ to only match the main estimator docstring. When running from step 2, checks for the modified estimators should then pass.

Please write in a comment of this issue, the estimator you are planning to work on. Note that some methods are shared between estimators and are located in other files e.g. estimator.set_params.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:34 (31 by maintainers)

github_iconTop GitHub Comments

1reaction
LauraLangdoncommented, Nov 2, 2019

I’m working on BernoulliNB.

0reactions
rsanjabicommented, Nov 2, 2019

Working on OPTICS

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validation — numpydoc v1.6.0rc1.dev0 Manual - Read the Docs
This will validate that the docstring can be built. For an exhaustive validation of the formatting of the docstring, use the --validate parameter....
Read more >
NumpyDoc Checking for conformity to the doc spec? [closed]
The closest thing I've come across is doccheck by @robert-t-mcgibbon: Check that all docstrings satisfy Numpy format.
Read more >
pandas docstring guide - Python-Sprints
numpydoc docstring guide (which is based in the original Guide to NumPy/SciPy ... For dict and tuple , as more than one type...
Read more >
numpydoc-lint - PyPI
Run numpydoc.validate on all docstrings in a package.
Read more >
Developing Documentation - sktime
sktime uses the numpydoc Sphinx extension and follows NumPy docstring format. ... However, the automated docstring validation in pydocstyle only covers ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found