numpy.positive#
- numpy.positive(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'positive'>#
数值正值,按元素.
- 参数:
- xarray_like 或标量
输入数组.
- 返回:
- yndarray 或标量
返回的数组或标量:y = +x .如果 x 是标量,则这是一个标量.
注释
等效于 x.copy() ,但仅为支持算术的类型定义.
示例
>>> import numpy as np
>>> x1 = np.array(([1., -1.])) >>> np.positive(x1) array([ 1., -1.])
一元运算符
+可以用作 ndarray 上np.positive的简写.>>> x1 = np.array(([1., -1.])) >>> +x1 array([ 1., -1.])