cf.Data.integral¶
-
Data.
integral
(axes=None, squeeze=False, mtol=1, weights=None, inplace=False, _preserve_partitions=False)[source]¶ Collapse axes with their integral.
If weights are not provided then all non-missing elements are given weighting of one such that the collapse method becomes a
sum
.- Parameters
- axes: (sequence of) int, optional
The axes to be collapsed. By default flattened input is used. Each axis is identified by its integer position. No axes are collapsed if axes is an empty sequence.
- squeeze:
bool
, optional If True then collapsed axes are removed. By default the axes which are collapsed are left in the result as axes with size 1, meaning that the result is guaranteed to broadcast correctly against the original array.
- weights: data-like or dict, optional
Weights associated with values of the array. By default all non-missing elements of the array are assumed to have a weight equal to one. If weights is a data-like object then it must have either the same shape as the array or, if that is not the case, the same shape as the axes being collapsed. If weights is a dictionary then each key is axes of the array (an int or tuple of ints) with a corresponding data-like value of weights for those axes. In this case, the implied weights array is the outer product of the dictionary’s values.
Note that the units of the weights matter for an integral collapse, which differs from a weighted sum in that the units of the weights are incorporated into the result.
- Parameter example:
If
weights={1: w, (2, 0): x}
thenw
must contain 1-dimensional weights for axis 1 andx
must contain 2-dimensional weights for axes 2 and 0. This is equivalent, for example, toweights={(1, 2, 0), y}
, wherey
is the outer product ofw
andx
. Ifaxes=[1, 2, 0]
thenweights={(1, 2, 0), y}
is equivalent toweights=y
. Ifaxes=None
and the array is 3-dimensional thenweights={(1, 2, 0), y}
is equivalent toweights=y.transpose([2, 0, 1])
.
mtol: number, optional
- Returns
Examples: