Numpy:获取有关添加功能的帮助
Numpy: Get help on the add function
我正在尝试编写一个简单的 NumPy 程序,以使用 google colab notebook 获得有关添加功能的帮助。
解决方法是:
print(np.info(np.add))
应该return:
add(x1, x2[, out])
Add arguments element-wise.
Parameters
----------
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).
Returns
-------
add : ndarray or scalar
The sum of `x1` and `x2`, element-wise. Returns a scalar if
both `x1` and `x2` are scalars.
Notes
-----
Equivalent to `x1` + `x2` in terms of array broadcasting.
Examples
--------
>>> np.add(1.0, 4.0)
5.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.]])
None
但我只得到:
None
如何获取函数文档?
numpy.info
没有 return 信息字符串。它直接打印到标准输出或您指定的另一个类似文件的对象。
一个 IPython 笔记本覆盖 sys.stdout
,但如果它这样做 after numpy.info
抓取 sys.stdout
用作默认参数,然后 numpy.info
最终尝试写入旧的标准输出。
告诉 numpy.info
显式打印到新的标准输出。此外,你不应该 print
return 值,除非你出于某种原因确实想要打印不相关的 None
。
numpy.info(numpy.add, output=sys.stdout)
我正在尝试编写一个简单的 NumPy 程序,以使用 google colab notebook 获得有关添加功能的帮助。
解决方法是:
print(np.info(np.add))
应该return:
add(x1, x2[, out])
Add arguments element-wise.
Parameters
----------
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).
Returns
-------
add : ndarray or scalar
The sum of `x1` and `x2`, element-wise. Returns a scalar if
both `x1` and `x2` are scalars.
Notes
-----
Equivalent to `x1` + `x2` in terms of array broadcasting.
Examples
--------
>>> np.add(1.0, 4.0)
5.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.]])
None
但我只得到:
None
如何获取函数文档?
numpy.info
没有 return 信息字符串。它直接打印到标准输出或您指定的另一个类似文件的对象。
一个 IPython 笔记本覆盖 sys.stdout
,但如果它这样做 after numpy.info
抓取 sys.stdout
用作默认参数,然后 numpy.info
最终尝试写入旧的标准输出。
告诉 numpy.info
显式打印到新的标准输出。此外,你不应该 print
return 值,除非你出于某种原因确实想要打印不相关的 None
。
numpy.info(numpy.add, output=sys.stdout)