Skip to content

Rewrite docstrings #1815

Closed
Closed

Description

@mrocklin

Currently we blindly copy dask.array and dask.dataframe docstrings from NumPy and Pandas. This allows us to avoid rewriting hundreds of docstrings.

However, this fails when the dask operation and the numpy/pandas operation differ slightly, as often occurs when we support only a subset of functionality. This appears to be confusing users who inspect our documentation, try something out, and then receive an error when it doesn't work (see this example).

There are some efforts to mitigate this, for example derived_from takes a list of unavailable arguments to add to the docstring. However this keyword argument is virtually unused.

Some solutions

  1. Crowd-sourced effort to rewrite docstrings manually
  2. Add disclaimer to all wrapped functions that it is merely a copy
  3. ?

Activity

  1. added
    documentation
    good first issue
    on Nov 28, 2016
  2. mrocklin commented on Nov 28, 2016

    @mrocklin
    MemberAuthor

    I'm somewhat more inclined towards option 2 to start because it is simple and comprehensive, if perhaps a bit blunt. We might be able to combine the two in some way, perhaps taking a small docstring from the dask.dataframe/array function and prepending it onto the pandas docstring in some clever way.

  3. mrocklin commented on Nov 28, 2016

    @mrocklin
    MemberAuthor

    Perhaps something like this, but better:

    """ Docstring for FUNCTION NAME
    
    This Dask function implements most of the functionality of WRAPPED FUNCTION NAME, whose complete docstring is included below.  However, this Dask version contains the following alterations:
    
    DOCSTRING FROM DASK FUNCTION
    
    The original docstring follows below:
    
    ORIGINAL DOCSTRING
    """
    
  4. soloz commented on Apr 4, 2017

    @soloz

    Hi,

    I've been using dask - thanks for the work. So its time to start giving back. For start, I'm happy to work on this, #1592 and #1606 and see how I get on with. Also happy to sync with anyone already doing so.

    Should put in a pr over the coming days.

  5. mrocklin commented on Apr 4, 2017

    @mrocklin
    MemberAuthor
  6. jaypeedevlin commented on Feb 14, 2018

    @jaypeedevlin

    I think some sort of re-ordering of the notes + explicit disclaimer would help a lot. There are some extreme cases, like this where all 5 of the listed parameters that are copied from the pandas docstring are not supported.

    image

    Does anyone know if the format of the pandas docstrings are consistent enough that we might be able to strip these params out in the derived_from() decorator

  7. mariusvniekerk commented on Jul 4, 2018

    @mariusvniekerk
    Contributor

    So theoretically the pandas docstrings should be adhering to numpydoc which you might be useful for parsing these.

  8. jakirkham commented on Aug 8, 2019

    @jakirkham
    Member

    I've added this to our core work list for triage.

  9. jsignell commented on Dec 11, 2019

    @jsignell
    Member

    I was thinking of trying to implement a generic disclaimer as described in this comment #1815 (comment). Do people still think that is a good idea?

  10. TomAugspurger commented on Feb 27, 2020

    @TomAugspurger
    Member

    Talking with @jsignell, we may want to just strip out parameters that aren't supported by dask.

    Rather than

    Parameters
    ----------
    rule : DateOffset, Timedelta or str
        The offset string or object representing target conversion.
    axis : {0 or 'index', 1 or 'columns'}, default 0  (Not supported in Dask)
        Which axis to use for up- or down-sampling. For `Series` this
        will default to 0, i.e. along the rows. Must be
        `DatetimeIndex`, `TimedeltaIndex` or `PeriodIndex`.
    closed : {'right', 'left'}, default None
    ...
    

    We'd have

    Parameters
    ----------
    rule : DateOffset, Timedelta or str
        The offset string or object representing target conversion.
    closed : {'right', 'left'}, default None
    ...
    
    Notes
    ------
    The following paramerts are not supported by dask
    
    * axis
    * ...
    
    

    or put that next to the dask disclaimer.

  11. TomAugspurger commented on Feb 27, 2020

    @TomAugspurger
    Member

    It would also be nice if the disclaimer included a link to the original docstring.

    Screen Shot 2020-02-27 at 5 40 19 PM

    That could be :meth:`pandas.DataFrame.resample`, rather than pandas.core.frame.DataFrame.resample.

    It's a bit tricky because the API doc location isn't always the same as where the object is defined (pandas.core.frame vs.pandas)

    The disclaimer should maybe be in an info box too.

  12. xmnlab commented on Jun 2, 2020

    @xmnlab

    I want to start contributing to dask and am interested in helping on this issue.

    I saw that @jsignell worked on some PRs related to this issue.

    is there missing anything to finish this issue? if yes I would be happy to help on that :)

  13. jsignell commented on Jun 2, 2020

    @jsignell
    Member

    @xmnlab thanks for expressing interest in this work! The suggestions that Tom made in this comment: #1815 (comment) and this one: #1815 (comment) are both still up for grabs and should probably be separated out into their own issues. So you could definitely work on either of those.

    Other than that I was just going through the rendered docs and seeing if any are derived docs that don't have the disclaimer. I never developed a more systematic approach, but if you do we may be able to finially close this ticket, which would be great!

  14. xmnlab commented on Jun 4, 2020

    @xmnlab

    thanks @jsignell for all the information! that sounds good. I will start it this weekend :)

  15. jsignell commented on Dec 9, 2020

    @jsignell
    Member

    I think we can close this at this point. There haven't been any issues in a while where people complained about docstrings that were missing the disclaimer, so maybe we hit them all with the brute force approach? Anyone should feel free to reopen if they disagree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions