Skip to content

Improving docstring wrapping functions #3265

Closed

Description

@jakirkham

We often reuse NumPy functions' docstrings. This is convenient as we don't take up maintaining docstrings (or more likely allowing them to go stale) when we don't have anything new to add. However there are few downsides to this approach (and possibly others I'm unaware of).

  1. NumPy versions show up (very confusing to users). ( Ensure select on dask arrays in GridInterface is lazy holoviz/holoviews#2424 (comment) )
  2. Arguments show up that are not fully or at all supported (also very confusing to users). ( da.repeat with repeats as list NotImplemented #2946 )
  3. Examples use NumPy instead of Dask.

Mainly these sorts of things confuse new users and leave them wondering about what Dask actually supports. This is not a great situation for us to be in. There are a few ways we can improve this.

  1. Manually copy and tweak docstrings when they deviate.
  2. Scrub things in our wrapper function (e.g. versionadded, missing args, examples).
  3. Add a note to the docs pointing out how the docstrings are made.
  4. Add any missing behavior (though still need to handle version added).

This could be an issue with Pandas too. I don't work with that part of the code enough to know.

Thoughts on this?

Activity

  1. added
    documentation
    on Mar 9, 2018
  2. changed the title [-]Improving docstring wrapping with NumPy functions[/-] [+]Improving docstring wrapping functions[/+] on Nov 30, 2018
  3. mrocklin commented on Nov 30, 2018

    @mrocklin
    Member

    This is also related to #1815

    In general I agree that there is definitely some work that we can do here. I suggest the following concrete steps:

    • First, we add a disclaimer to the top of the wrapped docstring automatically. For example this might look like the following:

      ORIGINAL TITLE OF DOCSTRING
      
      Note: this docstring was automatically copied from MODULE.FUNCTION_NAME
      Some discrepancies may exist between that function and this Dask version.
      <this is optional> In particular the parameters X, Y, and Z are unsupported </this is optional>
      
      ORIGINAL BODY OF DOCSTRING

      for example

      Compute the arithmetic mean along the specified axis.
      
      Note: this docstring was automatically copied from numpy.mean
      Some discrepancies may exist between that function and this Dask version.
      
      Returns the average of the array elements.  The average is taken over
      the flattened array by default, otherwise over the specified axis.
      `float64` intermediate and return values are used for integer inputs.
      

      The unsupported paramaters are made available if the person wrapping the function uses the ua_args keyword to the derived_from function, where all of this is done.

      def derived_from(original_klass, version=None, ua_args=[]):

    • If ua_args is not specified, and if the function signature uses neither *args nor **kwargs, then we inspect the function signatures of both the wrapped and wrapping functions and note any paramters that are missing automatically.

    This issue should be doable by someone with relatively little direct experience with Dask, but would be a very meaningful contribution. I'm marking this as a good first issue.

  4. added
    good first issue
    on Nov 30, 2018
  5. jakirkham commented on Nov 30, 2018

    @jakirkham
    MemberAuthor

    Ah did not see that issue when I opened this one. Happy to consolidate as needed.

  6. mrocklin commented on Nov 30, 2018

    @mrocklin
    Member

    Lets just stay here for now. The other one is more broad and suggests rewriting docstrings. This one focuses on the (I think) more likely solution of handling things systematically.

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