numpydoc
numpydoc copied to clipboard
[question] docstring Returns section not applicable for classes?
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
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.
vectorizeuses it mostly becausevectorizewas 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.
Thanks a lot. I understand then that this is an exception to the documentation guideline that is not worth documenting. Correct?