ndarray icon indicating copy to clipboard operation
ndarray copied to clipboard

Support for .multi_slice_axis_mut and .multi_slice_axis_move

Open imjasonmiller opened this issue 5 years ago • 0 comments

From #775:

We should add multi_slice_axis_mut and multi_slice_axis_move methods, in the same way that slice_axis_mut is analogous to slice_mut.

Are the methods multi_slice_axis_mut and multi_slice_axis_move still desired? I was looking for such functionality. If so, based on multi_slice_mut, is my understanding correct in that these two methods would make the following possible?

let mut example = array![
   [0, 0, 0],
   [0, 0, 0],
   [1, 2, 3],
   [4, 5, 6],
   [7, 8, 9],
   [0, 0, 0],
   [0, 0, 0],
];

let (mut pad_lo, mut pad_hi, mut edge_lo, mut edge_hi) =
    example.multi_slice_axis_mut(Axis(0), (s![..2], s![5..], s![2], s![4]));
// pad_lo:  [ [ 0, 0, 0 ],
//            [ 0, 0, 0 ] ]
// pad_hi:  [ [ 0, 0, 0 ],
//            [ 0, 0, 0 ] ]
// edge_lo: [ [ 1, 2, 3 ] ] 
// edge_hi: [ [ 7, 8, 9 ] ]

Although I'm still learning a lot about Rust, I would love to give implementing it a try, if the functionality is still on the to-do list.

It'd also come in handy for the ndarray-pad crate I'm working on!


I moved this into its own separate issue to not clutter the mentioned issue.

imjasonmiller avatar Jul 21 '20 07:07 imjasonmiller