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

Improve examples in docstrings #434

Open
bemoody opened this issue Nov 18, 2022 · 0 comments
Open

Improve examples in docstrings #434

bemoody opened this issue Nov 18, 2022 · 0 comments

Comments

@bemoody
Copy link
Collaborator

bemoody commented Nov 18, 2022

Pull request #433 brings to mind some things that could be improved in docstrings more generally. Cleaning these up might be a good starter issue.

  1. Obviously, code examples should be correct and actually work. :)

  2. Code examples should also be self-contained if possible, and avoid referring to files in sample-data (most people reading the documentation are probably not running the code directly from the git repository.) In most cases, it's better to use examples from published databases on PhysioNet.

  3. Code examples should be written in a consistent style. We generally use numpy style (https://numpydoc.readthedocs.io/en/latest/format.html) for docstrings, but we haven't been entirely consistent. In particular, numpy style requires examples to be written in "doctest" style, like this:

    """
    Examples
    --------
    >>> np.add([[1, 2], [3, 4]],
    ...        [[5, 6], [7, 8]])
    array([[ 6,  8],
           [10, 12]])
    """

This format has some nice properties (it can be tested automatically by doctest, and formatted nicely by sphinx.) On the other hand, the "..." is a little annoying when you want to copy and paste an example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant