flopscope.

flopscope.numpy.positive

fnp.positive(*args, **kwargs)[flopscope source][numpy source]

Numerical positive, element-wise.

Adapted from NumPy docs np.positive

Areacore
Typecounted
NumPy Refnp.positive
Cost
numel(output)\text{numel}(\text{output})
Flopscope Context

Element-wise unary plus (copy with sign preserved).

Parameters

x:array_like or scalar

Input array.

Returns

y:ndarray or scalar

Returned array or scalar: y = +x. This is a scalar if x is a scalar.

Notes

Equivalent to x.copy(), but only defined for types that support arithmetic.

Examples

>>> import flopscope.numpy as fnp
>>> x1 = flops.array(([1., -1.]))
>>> flops.positive(x1)
array([ 1., -1.])

The unary + operator can be used as a shorthand for flops.positive on ndarrays.

>>> x1 = flops.array(([1., -1.]))
>>> +x1
array([ 1., -1.])