-
Notifications
You must be signed in to change notification settings - Fork 338
Closed
Labels
enhancementgood first issueA good issue to start contributing to ndarray!A good issue to start contributing to ndarray!
Milestone
Description
Is there a reason why squeeze()
is not provided by the library? Its very useful.
I think it can be implemented fairly easily:
pub trait Squeeze {
fn squeeze(self) -> Self;
}
impl<S> Squeeze for ArrayBase<S, IxDyn>
where
S: RawData,
{
fn squeeze(self) -> Self {
let mut out = self;
for axis in (0..out.shape().len()).rev() {
if out.shape()[axis] == 1 && out.shape().len() > 1 {
out = out.remove_axis(Axis(axis));
}
}
out
}
}
Is there already such a function with a different name and i missed it?
Is there a problem with the implementation above?
Thanks for the support, this library is amazing!
Metadata
Metadata
Assignees
Labels
enhancementgood first issueA good issue to start contributing to ndarray!A good issue to start contributing to ndarray!