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.

Ensure that docstrings pass numpydoc validation

See original GitHub issue

Background / Objective

Docstrings in Python are string literals that occur as the first statement in a module, function, class, or method definition.

These are some of the characteristics of a docstring:

  • Triple quotes are used to encompass the docstring text.
  • There is no blank line before or after the docstring.
  • The docstring is a phrase ending in a period.
  • more details

numpydoc is one set of criteria to check for consistent documentation structure.

Validating docstrings in dirty_cat

To ensure consistent documentation structure in dirty_cat, we are using numpydoc validation. Currently, documentation tests are failing for various functions. As a temporary fix, we have suppressed error messages in test_docstrings.py. Many of the functions in dirty_cat need to be updated to comply with numpy docstring validation. In the below issue, we provide step-by-step instructions on how contributors can test and update functions.

Steps

  1. Make sure you have the development dependencies and documentation dependencies installed (see the contribution guidelines).
  2. Pick a function/class from the list below and leave a comment saying you are going to work on it. This way we can keep track of what everyone is working on. 2.1 Make sure you’ve created a separate branch from main before editing files for your new contribution. Refer to our contributing guidelines for more information.
  3. Remove the function from the list DOCSTRING_TEMP_IGNORE_SET in test_docstring.py.
  4. Let’s say you picked dirty_cat.gap_encoder.GapEncoder.fit, run numpydoc validation as follows.
pytest dirty_cat/tests/test_docstrings.py
  1. If you see the test fails, please fix them by following the recommendation provided by the failing test.
  2. If you see all the tests pass, you do not need to do any additional changes.
  3. Commit your changes.
  4. Open a Pull Request with an opening message Addresses #345. Note that each item should be submitted in a separate Pull Request.
  5. Include the function name in the title of the pull request. For example: “DOC Ensures that GapEncoder.fit passes numpydoc validation”.

Note: once you have issued 1-2 such PRs, feel free to move on to contributing more complex pull requests that involve more thinking and leave the other fixes to first time contributors for them to learn the github contribution workflow 😃

Functions to Update

  • dirty_cat._datetime_encoder.DatetimeEncoder #421
  • dirty_cat._datetime_encoder.DatetimeEncoder.fit #367
  • dirty_cat._datetime_encoder.DatetimeEncoder.get_feature_names
  • dirty_cat._datetime_encoder.DatetimeEncoder.get_feature_names_out
  • dirty_cat._datetime_encoder.DatetimeEncoder.transform #368
  • dirty_cat._gap_encoder.GapEncoder #438
  • dirty_cat._gap_encoder.GapEncoder.fit
  • dirty_cat._gap_encoder.GapEncoder.get_feature_names
  • dirty_cat._gap_encoder.GapEncoder.get_feature_names_out
  • dirty_cat._gap_encoder.GapEncoder.partial_fit
  • dirty_cat._gap_encoder.GapEncoder.score
  • dirty_cat._gap_encoder.GapEncoder.transform
  • dirty_cat._minhash_encoder.MinHashEncoder
  • dirty_cat._minhash_encoder.MinHashEncoder.fit
  • dirty_cat._minhash_encoder.MinHashEncoder.get_fast_hash
  • dirty_cat._minhash_encoder.MinHashEncoder.get_murmur_hash
  • dirty_cat._minhash_encoder.MinHashEncoder.transform
  • dirty_cat._similarity_encoder.SimilarityEncoder
  • dirty_cat._similarity_encoder.SimilarityEncoder.fit
  • dirty_cat._similarity_encoder.SimilarityEncoder.transform
  • dirty_cat._similarity_encoder.SimilarityEncoder.fit_transform
  • dirty_cat._super_vectorizer.SuperVectorizer #399
  • dirty_cat._super_vectorizer.SuperVectorizer.fit_transform
  • dirty_cat._super_vectorizer.SuperVectorizer.transform
  • dirty_cat._super_vectorizer.SuperVectorizer._auto_cast
  • dirty_cat._super_vectorizer.SuperVectorizer._apply_cast
  • dirty_cat._super_vectorizer.SuperVectorizer.get_feature_names
  • dirty_cat._super_vectorizer.SuperVectorizer.get_feature_names_out
  • dirty_cat._target_encoder.TargetEncoder
  • dirty_cat._target_encoder.TargetEncoder.fit
  • dirty_cat._target_encoder.TargetEncoder.transform
  • dirty_cat._fuzzy_join.fuzzy_join

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
alexdt1982commented, Sep 17, 2022

Validated DatetimeEncoder.transform.

1reaction
alexdt1982commented, Sep 16, 2022

Thanks for giving me the opportunity to contribute guys. Can I work on validating another function in DatetimeEncoder?

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 >
Documenting Python APIs with docstrings
(Note: one-line docstrings are rarely used for public APIs, see Numpydoc ... Always check the compiled documentation site to ensure the link worked....
Read more >
Indicating keyworded-ness of arguments in NumpyDoc ...
In trying to follow the NumpyDoc format for my DocStrings, I can't seem to figure out how to tell the user that an...
Read more >
flake8-docstrings - PyPI
Extension for flake8 which uses pydocstyle to check docstrings. ... The default is pep257, pydocstyle v2.0.0 added numpy (for the numpydoc standard), ...
Read more >
Supported hooks - pre-commit
validate -html - HTML syntax validator using W3C v.Nu checker, with support for ... velin - This hook attempt to reformat docstrings using...
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