numpydoc icon indicating copy to clipboard operation
numpydoc copied to clipboard

[question] docstring Returns section not applicable for classes?

Open kakila opened this issue 5 years ago • 3 comments

The documentation https://numpydoc.readthedocs.io/en/latest/format.html#id10 Says that the Returns section is not applicable in class docstrings.

What to do if the class implements __call__?

E.g. vectorize uses the section https://docs.scipy.org/doc/numpy/reference/generated/numpy.vectorize.html

Thanks

kakila avatar Nov 29 '19 20:11 kakila

vectorize uses it mostly because vectorize was made to look like a function. The fact that it is implemented as a class is an implementation detail. It even describes itself as "The vectorize function". The fact that it exposes __call__ is not why it has a Returns.

If you are documenting the behavior of __call__, that is the Parameters and the Returns for when you call the object, you document that in the docstring of __call__, not the class.

rkern avatar Dec 02 '19 21:12 rkern

vectorize uses it mostly because vectorize was made to look like a function.

To clarify (as this is ambiguous): because the class itself, not its instances, was made to look like a function. The fact that its instances are also callable didn't motivate the Returns sections. That Returns sections does not describe the return values of the instances.

rkern avatar Dec 02 '19 21:12 rkern

Thanks a lot. I understand then that this is an exception to the documentation guideline that is not worth documenting. Correct?

kakila avatar Dec 03 '19 06:12 kakila