Getting help and finding documentation

Getting help and finding documentation#

Author: Emmanuelle Gouillart

Rather than knowing all functions in NumPy and SciPy, it is important to find information throughout the documentation and the available help. Here are some ways to get information:

help in Jupyter and IPython#

In the Jupyter notebook, and in IPython terminals, one can use the help function to see the docstring of any particular function. For example:

import numpy as np

help(np.around)
Help on _ArrayFunctionDispatcher in module numpy:

around(a, decimals=0, out=None)
    Round an array to the given number of decimals.

    `around` is an alias of `~numpy.round`.

    See Also
    --------
    ndarray.round : equivalent method
    round : alias for this function
    ceil, fix, floor, rint, trunc

Jupyter and IPython also recognize ? at the end of the function name as a request to the function docstring, so executing:

np.around?

is equivalent to executing help(around).

You only need type the beginning of the function’s name and use tab completion to display the matching functions. For example, if you were interesting the np.vander function, you can type the Tab key after np.van to tab complete to the only function starting with np.van (np.vander).

# Uncomment, and press Tab at the end of `np.van` to show tab completion.
# np.van

In the standard Ipython terminal, it is not possible to open a separate window for help and documentation; however one can always open a second Ipython shell just to display help and docstrings…

Online documentation#

Numpy’s and Scipy’s documentations can be browsed online on https://scipy.org and https://numpy.org. The search button is quite useful inside the reference documentation of the two packages.

Tutorials on various topics as well as the complete API with all docstrings are found on this website.

The SciPy Cookbook https://scipy-cookbook.readthedocs.io gives recipes on many common problems frequently encountered, such as fitting data points, solving ODE, etc.

Matplotlib’s website https://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.

psearch#

Jupyter and IPython have a magic function %psearch to search for objects matching patterns. This is useful if, for example, one does not know the exact name of a function.

%psearch np.diag*

If all else fails#

If everything listed above fails (and Google doesn’t have the answer)… don’t despair! There is a vibrant Scientific Python community. Scientific Python is present on various platform. https://scientific-python.org/community/

Packages like SciPy and NumPy also have their own channels. Have a look at their respective websites to find out how to engage with users and maintainers.