Skip to main content

mean_where

Function mean_where 

Source
pub fn mean_where<T, D>(
    a: &Array<T, D>,
    axis: Option<usize>,
    where_mask: Option<&Array<bool, IxDyn>>,
) -> Result<Array<T, IxDyn>, FerrayError>
where T: Element + Float, D: Dimension,
Expand description

Mean reduction with a where mask.

Equivalent to np.mean(a, axis=axis, where=where_mask). The divisor is the count of true positions in the (broadcast) mask, NOT the lane length — fully-masked-out lanes return T::nan() (matching NumPy’s “RuntimeWarning: Mean of empty slice” behavior, but without the warning machinery). initial is intentionally not modeled because the divisor for an “initial-bumped” mean is ambiguous in NumPy too. where_mask is broadcast-compatible with a.shape() (#565).