sum#
- class saiunit.math.sum(x, axis=None, dtype=None, keepdims=False, initial=None, where=None, promote_integers=True, **kwargs)#
Return the sum of the array elements.
- Parameters:
x (saiunit.Quantity |
Array|ndarray|bool|number|bool|int|float|complex) – Input array.axis (
int|Sequence[int] |None) –Axis or axes along which a sum is performed. The default, axis=None, will sum all of the elements of the input array. If axis is negative it counts from the last to the first axis.
If axis is a tuple of ints, a sum is performed on all of the axes specified in the tuple instead of a single axis or all the axes as before.
dtype (
str|type[Any] |dtype|SupportsDType|None) – The type of the returned array and of the accumulator in which the elements are summed. The dtype of a is used by default unless a has an integer dtype of less precision than the default platform integer. In that case, if a is signed then the platform integer is used while if a is unsigned then an unsigned integer of the same precision as the platform integer is used.keepdims (
bool) –If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.
If the default value is passed, then keepdims will not be passed through to the sum method of sub-classes of ndarray, however any non-default value will be. If the sub-class’ method does not implement keepdims any exceptions will be raised.
initial (
Array|ndarray|bool|number|bool|int|float|complex| saiunit.Quantity |None) – Starting value for the sum. See ~numpy.ufunc.reduce for details.where (
Array|ndarray|bool|number|bool|int|float|complex|None) – Elements to include in the sum. See ~numpy.ufunc.reduce for details.promote_integers (
bool) – If True, and if the accumulator is an integer type, then the
- Returns:
out – Quantity if x is a Quantity, else an array.
- Return type:
saiunit.Quantity |
Array
Examples
>>> import saiunit as u >>> a = [1.0, 2.0, 3.0] * u.second >>> u.math.sum(a)