[Numpy-discussion] docstring suggestions
Sat Feb 13 23:53:19 CST 2010
On Feb 13, 2010, at 11:56 PM, David Goldsmith wrote:
> Please don't misinterpret my statements to mean that I think this isn't important and/or that you should feel solely responsible for a fix - I sincerely just wanted to uncover the nature and extent of the problem. Unfortunately, I still feel like I don't really understand the functional origin of the problem, otherwise I'd be the first to be offering to help - perhaps if you can explain to me what you think is happening...
In a nutshell:
some functions in numpy.ma (like np.ma.compress) are actually instances of a factory class (_frommethod). This class implements a __call__ method, so its instances behave like functions. In practice, they just call a method of MaskedArray. Anyway, the __doc__ of the instance is created from the docstring of the corresponding method with _frommethod.getdoc. I'm sure that's where we can improve things (like substistute `self `by `a`.
Because it's an instance, help(numpy.ma.compress) gives the docstring of numpy.ma._frommethod instead. In IPython, numpy.ma.compress? gives you the doc, twice (I don't get why).
More information about the NumPy-Discussion