1.6. 获取帮助和查找文档¶
Author: Emmanuelle Gouillart
比知道Numpy和Scipy中的所有函数重要的是在整个文档和可用的帮助中快速找到信息。Here are some ways to get information:
In Ipython,
help function
opens the docstring of the function. Only type the beginning of the function’s name and use tab completion to display the matching functions.In [204]: help np.v np.vander np.vdot np.version np.void0 np.vstack np.var np.vectorize np.void np.vsplit In [204]: help np.vander
在Ipython中,它不能打开一个单独窗口的帮助和文档;而你可以一直打开另外一个Ipython
shell,只是为了显示帮助和文档字符串等。
Numpy’s and Scipy’s documentations can be browsed online on http://docs.scipy.org/doc.
search
按钮在两个包的参考文档中非常有用(http://docs.scipy.org/doc/numpy/reference/和http://docs.scipy.org/doc/scipy/reference/)。在这个网站上可以找到各种主题的教程以及带有文档字符串的所有的完整API。
Numpy’s and Scipy’s documentation is enriched and updated on a regular basis by users on a wiki http://docs.scipy.org/doc/numpy/. 因此,一些文档字符串在wiki上更清晰或更详细,你可能想直接阅读wiki上的文档,而不是官方文档网站。请注意,任何人都可以在wiki上创建一个帐户,并编写更好的文档;这是一个简单的方法来贡献一个开源项目并改进你使用的工具!
Scipy central http://central.scipy.org/ gives recipes on many common problems frequently encountered, such as fitting data points, solving ODE, etc.
Matplotlib’s website http://matplotlib.org/ features a very nice gallery with a large number of plots, each of them shows both the source code and the resulting plot. This is very useful for learning by example. More standard documentation is also available.
最后,另外两个“技术”可能也是有用的:
In Ipython, the magical function
%psearch
search for objects matching patterns. This is useful if, for example, one does not know the exact name of a function.In [3]: import numpy as np In [4]: %psearch np.diag* np.diag np.diagflat np.diagonal
numpy.lookfor looks for keywords inside the docstrings of specified modules.
In [45]: numpy.lookfor('convolution') Search results for 'convolution' -------------------------------- numpy.convolve Returns the discrete, linear convolution of two one-dimensional sequences. numpy.bartlett Return the Bartlett window. numpy.correlate Discrete, linear correlation of two 1-dimensional sequences. In [46]: numpy.lookfor('remove', module='os') Search results for 'remove' --------------------------- os.remove remove(path) os.removedirs removedirs(path) os.rmdir rmdir(path) os.unlink unlink(path) os.walk Directory tree generator.
If everything listed above fails (and Google doesn’t have the answer)... don’t despair! 向适合你的问题的邮件列表写一封邮件:如果你很好地描述你的问题,你应该有一个快速的答案。Experts on scientific python often give very enlightening explanations on the mailing-list.
- Numpy讨论(numpy-discussion@scipy.org):关于numpy数组、操作它们、索引问题,等等。
- SciPy用户列表(scipy-user@scipy.org):使用Python进行科学计算、高级数据加工、特别是用scipy包。
- 针对matplotlib画图:matplotlib-users@lists.sourceforge.net。