-
Notifications
You must be signed in to change notification settings - Fork 358
Add support for slicing with subviews #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Very nice work! 💟 |
5507f38 to
047e79f
Compare
New changesI just force-pushed two additional changes:
Experiences using this PR, and a potential
|
|
Indeed, it seems like a useful type. Note the merge conflict on the PR. I don't mind further rebases and edits on PRs. |
`ndarray` guarantees support for only the latest stable version of Rust, so removing Rust 1.18.0 from continuous integration testing allows us to take advantage of new features.
047e79f to
8413825
Compare
|
I rebased the PR off of the latest master and added the |
|
Please derive Copy for it. If we go back to the Range situation, it could have been solved by making it implement IntoIterator, not Iterator. |
34640e3 to
2d4ceab
Compare
Okay, done.
Good point. I guess |
|
One more change I'm considering is adding field names ( Edit: The third field name will have to be |
|
fields and methods can have the same name, fwiw, but it's good to dwell on the situation. |
Woah, I had no idea. That would be confusing, though. Apparently you call a method with I think I'd like to use field names |
|
that sounds fine |
Also rename .step() to .step_by().
d70e67a to
79659c9
Compare
|
Thanks a lot for this huge work, for working through it and putting it into such a well disposed form in this PR! 🌟 💯 |
This is a cleaned-up version of PR #369, and it fixes #215. The history is organized into self-contained commits, and each commit passes all tests.
The changes are:
.isubview()to.subview_inplace()..islice()to.slice_inplace().ndarray::simodule tondarray::slicesince theSitype is removed..slice_axis(),.slice_axis_mut(), and.slice_axis_inplace()methods toArrayBase.do_slice()tondarray::dimension, and removeDimension::do_slices()because it's no longer needed.abs_index()from thedimension_traitmodule to thedimensionmodule and change itslenargument to typeIx.NDIM: Option<usize>associated constant toDimensiontrait.zero_index_with_ndim()toDimensiontrait.Siinto an enumSliceOrIndex.Dimension::SliceArgto[SliceOrIndex; n]or[SliceOrIndex].SliceInfothat stores an array/vec/slice ofSliceOrIndexand the dimension type after slicing..slice*()methods to&SliceInfo..slice_move()method.s![]macro to return a&SliceInfo<[SliceOrIndex; n], Do>.Of those, the user-visible changes are 2, 3, 5, 8, and 10. (Technically, 6 and 9 are too, but they're hidden from the docs.) Changes 2, 3, and 10 are breaking changes. (Technically, 6 is too, but
do_slices()was hidden from the docs.)In the future, it would be nice to make slicing more ergonomic in some cases where the user currently has to call
.as_ref()on the&SliceInfoinstance. (Seetest_slice_dyninput_array_fixed,test_slice_dyninput_array_dyn,test_slice_dyninput_vec_fixed, andtest_slice_dyninput_vec_dynintests/array.rs.)