ndarray-stats icon indicating copy to clipboard operation
ndarray-stats copied to clipboard

(min/max)_axis(_skipnan)

Open sebasv opened this issue 5 years ago • 2 comments

A common use case for me is taking the min or max over one axis of a multidimensional array, much like quantile_axis_mut, except I don't want to mutate my original data and I don't need the overhead of tracking quantiles. I couldn't find mentions of this idea in other issues. Will you consider a PR for such methods? I was thinking along the lines of

pub trait QuantileExt<A, S, D>
where
    S: Data<Elem = A>,
    D: Dimension,
{
    fn min_axis_skipnan(
        &self,
        axis: Axis,
    ) -> Array<A, D::Smaller>
    where
        D: RemoveAxis,
        A: Ord + Clone + MaybeNan,
        A::NotNan: Ord;
}

sebasv avatar Aug 05 '20 08:08 sebasv

I would also find this useful. I'm currently using something like:

data.map_axis(Axis(0), |col| col.min_skipnan().clone())

jtrawinski avatar Aug 06 '20 03:08 jtrawinski

Given that the skipnan functionality is not available in ndarray itself I'd say that this would be a good addition for convenience :+1:

LukeMathWalker avatar Aug 06 '20 05:08 LukeMathWalker