10000 Add support for inserting new axes while slicing by jturner314 · Pull Request #570 · rust-ndarray/ndarray · GitHub
[go: up one dir, main page]

Skip to content

Add support for inserting new axes while slicing #570

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

Merged
merged 28 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
24a3299
Rename SliceOrIndex to AxisSliceInfo
jturner314 Dec 9, 2018
6a16b88
Switch from Dimension::SliceArg to CanSlice trait
jturner314 Dec 9, 2018
546b69c
Add support for inserting new axes while slicing
jturner314 Dec 9, 2018
6e335ca
Rename SliceInfo generic params to Din and Dout
jturner314 Dec 17, 2018
d6b9cb0
Improve code style
jturner314 Dec 17, 2018
438d69a
Derive Clone, Copy, and Debug for NewAxis
jturner314 Dec 17, 2018
6050df3
Use stringify! for string literal of type name
jturner314 Dec 18, 2018
8d45268
Make step_by panic for variants other than Slice
jturner314 Dec 18, 2018
1d15275
Add DimAdd trait
jturner314 Dec 18, 2018
41cc4a1
Replace SliceNextIn/OutDim with SliceArg trait
jturner314 Dec 18, 2018
c66ad8c
Combine DimAdd impls for Ix0
jturner314 Feb 7, 2021
7776bfc
Implement CanSlice<IxDyn> for [AxisSliceInfo]
jturner314 Feb 14, 2021
ab79d28
Change SliceInfo to be repr(transparent)
jturner314 Feb 15, 2021
615113e
Add debug assertions to SliceInfo::new_unchecked
jturner314 Feb 15, 2021
e66e3c8
Fix safety of SliceInfo::new
jturner314 Feb 15, 2021
3ba6ceb
Add some impls of TryFrom for SliceInfo
jturner314 Feb 15, 2021
815e708
Make slice_move not call slice_collapse
jturner314 Feb 16, 2021
25a7bb0
Make slice_collapse return Err(_) for NewAxis
jturner314 Feb 16, 2021
5202a50
Expose CanSlice trait in public API
jturner314 Feb 16, 2021
319701d
Expose MultiSlice trait in public API
jturner314 Feb 16, 2021
d5d6482
Add DimAdd bounds to Dimension trait
jturner314 Feb 16, 2021
9614b13
Revert "Make slice_collapse return Err(_) for NewAxis"
jturner314 Feb 17, 2021
61cf7c0
Make slice_collapse panic on NewAxis
jturner314 Feb 17, 2021
91dbf3f
Rename DimAdd::Out to DimAdd::Output
jturner314 Feb 17, 2021
5dc77bd
Rename SliceArg to SliceNextDim
jturner314 Feb 17, 2021
87515c6
Rename CanSlice to SliceArg
jturner314 Feb 17, 2021
c4efbbf
Rename MultiSlice to MultiSliceArg
jturner314 Feb 17, 2021
7506f90
Clarify docs of .slice_collapse()
jturner314 Feb 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename MultiSlice to MultiSliceArg
  • Loading branch information
jturner314 authored and bluss committed Mar 12, 2021
commit c4efbbfca33e1d993f0216b0bb32a6652a89f74a
9 changes: 5 additions & 4 deletions src/impl_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::iter::{
AxisChunksIter, AxisChunksIterMut, AxisIter, AxisIterMut, ExactChunks, ExactChunksMut,
IndexedIter, IndexedIterMut, Iter, IterMut, Lanes, LanesMut, Windows,
};
use crate::slice::{MultiSlice, SliceArg};
use crate::slice::{MultiSliceArg, SliceArg};
use crate::stacking::concatenate;
use crate::{AxisSliceInfo, NdIndex, Slice};

Expand Down Expand Up @@ -363,8 +363,9 @@ where

/// Return multiple disjoint, sliced, mutable views of the array.
///
/// See [*Slicing*](#slicing) for full documentation.
/// See also [`s!`], [`SliceArg`], and [`SliceInfo`](crate::SliceInfo).
/// See [*Slicing*](#slicing) for full documentation. See also
/// [`MultiSliceArg`], [`s!`], [`SliceArg`], and
/// [`SliceInfo`](crate::SliceInfo).
///
/// **Panics** if any of the following occur:
///
Expand All @@ -385,7 +386,7 @@ where
/// ```
pub fn multi_slice_mut<'a, M>(&'a mut self, info: M) -> M::Output
where
M: MultiSlice<'a, A, D>,
M: MultiSliceArg<'a, A, D>,
S: DataMut,
{
info.multi_slice_move(self.view_mut())
Expand Down
9 changes: 5 additions & 4 deletions src/impl_views/splitting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// except according to those terms.

use crate::imp_prelude::*;
use crate::slice::MultiSlice;
use crate::slice::MultiSliceArg;

/// Methods for read-only array views.
impl<'a, A, D> ArrayView<'a, A, D>
Expand Down Expand Up @@ -117,8 +117,9 @@ where
/// consumes `self` and produces views with lifetimes matching that of
/// `self`.
///
/// See [*Slicing*](#slicing) for full documentation. See also [`s!`],
/// [`SliceArg`](crate::SliceArg), and [`SliceInfo`](crate::SliceInfo).
/// See [*Slicing*](#slicing) for full documentation. See also
/// [`MultiSliceArg`], [`s!`], [`SliceArg`](crate::SliceArg), and
/// [`SliceInfo`](crate::SliceInfo).
///
/// [`.multi_slice_mut()`]: struct.ArrayBase.html#method.multi_slice_mut
///
Expand All @@ -129,7 +130,7 @@ where
/// * if `D` is `IxDyn` and `info` does not match the number of array axes
pub fn multi_slice_move<M>(self, info: M) -> M::Output
where
M: MultiSlice<'a, A, D>,
M: MultiSliceArg<'a, A, D>,
{
info.multi_slice_move(self)
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub use crate::dimension::NdIndex;
pub use crate::error::{ErrorKind, ShapeError};
pub use crate::indexes::{indices, indices_of};
pub use crate::slice::{
AxisSliceInfo, MultiSlice, NewAxis, Slice, SliceArg, SliceInfo, SliceNextDim,
AxisSliceInfo, MultiSliceArg, NewAxis, Slice, SliceArg, SliceInfo, SliceNextDim,
};

use crate::iterators::Baseiter;
Expand Down
12 changes: 6 additions & 6 deletions src/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ macro_rules! s(
///
/// It's unfortunate that we need `'a` and `A` to be parameters of the trait,
/// but they're necessary until Rust supports generic associated types.
pub trait MultiSlice<'a, A, D>
pub trait MultiSliceArg<'a, A, D>
where
A: 'a,
D: Dimension,
Expand All @@ -921,7 +921,7 @@ where
private_decl! {}
}

impl<'a, A, D> MultiSlice<'a, A, D> for ()
impl<'a, A, D> MultiSliceArg<'a, A, D> for ()
where
A: 'a,
D: Dimension,
Expand All @@ -933,7 +933,7 @@ where
private_impl! {}
}

impl<'a, A, D, I0> MultiSlice<'a, A, D> for (&I0,)
impl<'a, A, D, I0> MultiSliceArg<'a, A, D> for (&I0,)
where
A: 'a,
D: Dimension,
Expand All @@ -953,7 +953,7 @@ macro_rules! impl_multislice_tuple {
impl_multislice_tuple!(@def_impl ($($but_last,)* $last,), [$($but_last)*] $last);
};
(@def_impl ($($all:ident,)*), [$($but_last:ident)*] $last:ident) => {
impl<'a, A, D, $($all,)*> MultiSlice<'a, A, D> for ($(&$all,)*)
impl<'a, A, D, $($all,)*> MultiSliceArg<'a, A, D> for ($(&$all,)*)
where
A: 'a,
D: Dimension,
Expand Down Expand Up @@ -995,11 +995,11 @@ impl_multislice_tuple!([I0 I1 I2] I3);
impl_multislice_tuple!([I0 I1 I2 I3] I4);
impl_multislice_tuple!([I0 I1 I2 I3 I4] I5);

impl<'a, A, D, T> MultiSlice<'a, A, D> for &T
impl<'a, A, D, T> MultiSliceArg<'a, A, D> for &T
where
A: 'a,
D: Dimension,
T: MultiSlice<'a, A, D>,
T: MultiSliceArg<'a, A, D>,
{
type Output = T::Output;

Expand Down
0