-
Notifications
You must be signed in to change notification settings - Fork 350
Open
Labels
enhancementgood first issueA good issue to start contributing to ndarray!A good issue to start contributing to ndarray!
Description
One of my function needs to create a new array with the same order as the input. I know I can use clone() when both arrays have the same dimension, but when it's not the case, it's more complex.
fn binary_dilation(mask: &Array3<bool>) -> Array3<bool> {
let (width, height, depth) = mask.dim();
let dim = (width + etc., ...);
let mut new_mask = if mask.is_standard_layout() {
Array3::from_elem(dim, false)
} else {
Array3::from_elem(dim.f(), false)
};
// Do something
}
Is there a one-liner for this? Something like
Array3::from_elem(dim.order_of(mask), false)
or anytning that doesn't require an if?
Metadata
Metadata
Assignees
Labels
enhancementgood first issueA good issue to start contributing to ndarray!A good issue to start contributing to ndarray!