Numpy: Get help on the add function

I am trying to write a simple NumPy program to get help on the add function using google colab notebook.

The solution is:


It should return:

add(x1, x2[, out])

Add arguments element-wise.

x1, x2 : array_like
    The arrays to be added.  If ``x1.shape != x2.shape``, they must be
    broadcastable to a common shape (which may be the shape of one or
    the other).

add : ndarray or scalar
    The sum of `x1` and `x2`, element-wise.  Returns a scalar if
    both  `x1` and `x2` are scalars.

Equivalent to `x1` + `x2` in terms of array broadcasting.

>>> np.add(1.0, 4.0)
>>> x1 = np.arange(9.0).reshape((3, 3))
>>> x2 = np.arange(3.0)
>>> np.add(x1, x2)
array([[  0.,   2.,   4.],
       [  3.,   5.,   7.],
       [  6.,   8.,  10.]])

But I get only:

How could I get the function documentation?

>Solution : doesn’t return an info string. It prints straight to stdout, or another file-like object you specify.

An IPython notebook overrides sys.stdout, but if it does so after grabs sys.stdout to use as a default parameter, then ends up trying to write to the old stdout.

Tell to print to the new stdout explicitly. Also, you shouldn’t print the return value unless you actually do want to print an irrelevant None for some reason., output=sys.stdout)

Leave a Reply