[Numpy-discussion] Proposed enhancement to "Returns" section for numpy doc strings
rob at relentlessidiot.com
Tue Jun 25 02:52:11 EDT 2013
I am an admirer of the numpy doc string style. I'd like to propose a simple
enhancement to the Returns section that should make the common case more
readable, while maintaining backward compatibility with existing
The current numpy documentation spec  requires that return values are
named. Most of the time I only care about the return *type* of a function,
and I can't be bothered to come up with a name. Of course, I can use the
default "out" return name, but that adds nothing of value to the
documentation, and takes away from the readability. I'd really like to just
True if some condition, False otherwise.
Of course there are times when names can *enhance* the documentation, for
X1, X2,..., XN : ndarray
For vectors `x1`, `x2`,..., 'xn' with lengths ``Ni=len(xi)`` ,
return ``(N1, N2, N3,...Nn)`` shaped arrays if indexing='ij'
or ``(N2, N1, N3,...Nn)`` shaped arrays if indexing='xy'
with the elements of `xi` repeated to fill the matrix along
the first dimension for `x1`, the second for `x2` and so on.
I suggest that the *name* of each return value should be optional, while
the *type* is required. This would allow for the common case, while still
supporting the documentation as it stands.
I've implemented this change in the numpydoc_returns_unnamed feature branch
on my github fork. The numpydoc sphinx extension has been updated, as well
as the reStructuredText example.py and the guide to numpy documentation.
Please review my pull request (https://github.com/numpy/numpy/pull/3468)
and let me know what you think.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion