You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider alternative syntax for slicing (Index and IndexMut)? #1311
Compared to Python, ndarray crate has an obvious difference in slicing. Arguably, this is the most annoying part of ndarray library. It would be nice to be able to do something like the following:
let a = SomeMatrix::default();let y = &a[1]);let x = &a[1..3]
let z= &a[[1..3,4..3]]);
Now with ndarray, this code would look quite nasty, but it does not have to. Rust does allow the Index operator (i.e., [])to be "overloaded" depending on the type of whatever is being used as "indexer", as in the example below:
There are several "blindspots" here (such as inability to "collapse" dimensions when range is empty or contains only one element, or mix range and integer slicing), but the key question is whether the ndarray users find it useful/appropriate to make the necessary changes to the crate to enable this at all.
Activity