Trait ndarray_stats::MaybeNanExt
source · pub trait MaybeNanExt<A, S, D>where
A: MaybeNan,
S: Data<Elem = A>,
D: Dimension,{
fn fold_skipnan<'a, F, B>(&'a self, init: B, f: F) -> B
where
A: 'a,
F: FnMut(B, &'a A::NotNan) -> B;
fn visit_skipnan<'a, F>(&'a self, f: F)
where
A: 'a,
F: FnMut(&'a A::NotNan);
fn fold_axis_skipnan<B, F>(
&self,
axis: Axis,
init: B,
fold: F
) -> Array<B, D::Smaller>
where
D: RemoveAxis,
F: FnMut(&B, &A::NotNan) -> B,
B: Clone;
fn map_axis_skipnan_mut<'a, B, F>(
&'a mut self,
axis: Axis,
mapping: F
) -> Array<B, D::Smaller>
where
A: 'a,
S: DataMut,
D: RemoveAxis,
F: FnMut(ArrayViewMut1<'a, A::NotNan>) -> B;
}
Expand description
Extension trait for ArrayBase
providing NaN-related functionality.
Required Methods
sourcefn fold_skipnan<'a, F, B>(&'a self, init: B, f: F) -> Bwhere
A: 'a,
F: FnMut(B, &'a A::NotNan) -> B,
fn fold_skipnan<'a, F, B>(&'a self, init: B, f: F) -> Bwhere
A: 'a,
F: FnMut(B, &'a A::NotNan) -> B,
Traverse the non-NaN array elements and apply a fold, returning the resulting value.
Elements are visited in arbitrary order.
sourcefn visit_skipnan<'a, F>(&'a self, f: F)where
A: 'a,
F: FnMut(&'a A::NotNan),
fn visit_skipnan<'a, F>(&'a self, f: F)where
A: 'a,
F: FnMut(&'a A::NotNan),
Visit each non-NaN element in the array by calling f
on each element.
Elements are visited in arbitrary order.
sourcefn fold_axis_skipnan<B, F>(
&self,
axis: Axis,
init: B,
fold: F
) -> Array<B, D::Smaller>where
D: RemoveAxis,
F: FnMut(&B, &A::NotNan) -> B,
B: Clone,
fn fold_axis_skipnan<B, F>(
&self,
axis: Axis,
init: B,
fold: F
) -> Array<B, D::Smaller>where
D: RemoveAxis,
F: FnMut(&B, &A::NotNan) -> B,
B: Clone,
Fold non-NaN values along an axis.
Combine the non-NaN elements of each subview with the previous using the fold function and initial value init.
sourcefn map_axis_skipnan_mut<'a, B, F>(
&'a mut self,
axis: Axis,
mapping: F
) -> Array<B, D::Smaller>where
A: 'a,
S: DataMut,
D: RemoveAxis,
F: FnMut(ArrayViewMut1<'a, A::NotNan>) -> B,
fn map_axis_skipnan_mut<'a, B, F>(
&'a mut self,
axis: Axis,
mapping: F
) -> Array<B, D::Smaller>where
A: 'a,
S: DataMut,
D: RemoveAxis,
F: FnMut(ArrayViewMut1<'a, A::NotNan>) -> B,
Reduce the values along an axis into just one value, producing a new array with one less dimension.
The NaN values are removed from the 1-dimensional lanes, then they are passed as mutable views to the reducer, allowing for side-effects.
Warnings:
-
The lanes are visited in arbitrary order.
-
The order of the elements within the lanes is unspecified. However, if
mapping
is idempotent, this method is idempotent. Additionally, given the same input data, the lane is always ordered the same way.
Panics if axis
is out of bounds.