diff#
- class brainunit.math.diff(x, n=1, axis=-1, prepend=None, append=None, **kwargs)#
Return the differences between consecutive elements of the array.
- Parameters:
x (saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex) – Input array.n (
int) – The number of times values are differenced. If zero, the input is returned as-is.axis (
int) – The axis along which the difference is taken, default is the last axis.prepend (
Array|ndarray|bool|number|bool|int|float|complex| saiunit.Quantity |None) – Values to prepend or append to a along axis prior to performing the difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match a except along axis.append (
Array|ndarray|bool|number|bool|int|float|complex| saiunit.Quantity |None) – Values to prepend or append to a along axis prior to performing the difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match a except along axis.
- Returns:
out – Quantity if x is a Quantity, else an array.
- Return type:
saiunit.Quantity |
Array
Examples
>>> import saiunit as u >>> a = [1, 2, 4, 7] * u.meter >>> u.math.diff(a)