numpy.positive#
- numpy.positive(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature]) = <ufunc 'positive'>#
數值正值,逐元素運算。
- 參數:
- x類陣列或純量
輸入陣列。
- 回傳:
- 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.])