[Numpy-discussion] How to get docs for functions processed by numpy.vectorize?

John Haiducek jhaiduce at gmail.com
Thu Sep 11 11:46:35 EDT 2014

When I apply numpy.vectorize() to a function, documentation tools behave 
inconsistently with regard to the new, vectorized function. The 
function's __doc__ attribute does contain the docstring of the original 
function as expected, but the built-in help() command displays the 
documentation of the numpy.vectorize class, and sphinx-autodoc fails to 
display the function at all. Is there a way to get sphinx-autodoc and 
the built-in help() command to display the docstring of the function and 
not something else?

For instance:

>>> import numpy as np
>>> def myfunc(x):
...     "Square x"
...     return x**2
>>> myfunc=np.vectorize(myfunc)
>>> print myfunc.__doc__
Square x
>>> help(myfunc)
(displays documentation of np.vectorize)

More information about the NumPy-Discussion mailing list