Skip to content

Commit 7e7777f

Browse files
committed
Rename SliceOrIndex to AxisSliceInfo
1 parent a66f364 commit 7e7777f

File tree

8 files changed

+112
-112
lines changed

8 files changed

+112
-112
lines changed

blas-tests/tests/oper.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ extern crate num_traits;
66
use ndarray::linalg::general_mat_mul;
77
use ndarray::linalg::general_mat_vec_mul;
88
use ndarray::prelude::*;
9+
use ndarray::{AxisSliceInfo, Ix, Ixs, SliceInfo};
910
use ndarray::{Data, LinalgScalar};
10-
use ndarray::{Ix, Ixs, SliceInfo, SliceOrIndex};
1111
use std::iter::FromIterator;
1212

1313
use approx::{assert_abs_diff_eq, assert_relative_eq};
@@ -421,11 +421,11 @@ fn scaled_add_3() {
421421
let mut answer = a.clone();
422422
let cdim = if n == 1 { vec![q] } else { vec![n, q] };
423423
let cslice = if n == 1 {
424-
vec![SliceOrIndex::from(..).step_by(s2)]
424+
vec![AxisSliceInfo::from(..).step_by(s2)]
425425
} else {
426426
vec![
427-
SliceOrIndex::from(..).step_by(s1),
428-
SliceOrIndex::from(..).step_by(s2),
427+
AxisSliceInfo::from(..).step_by(s1),
428+
AxisSliceInfo::from(..).step_by(s2),
429429
]
430430
};
431431

src/dimension/dimension_trait.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::Axis;
1919
use crate::IntoDimension;
2020
use crate::RemoveAxis;
2121
use crate::{ArrayView1, ArrayViewMut1};
22-
use crate::{Dim, Ix, Ix0, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn, IxDynImpl, Ixs, SliceOrIndex};
22+
use crate::{AxisSliceInfo, Dim, Ix, Ix0, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn, IxDynImpl, Ixs};
2323

2424
/// Array shape and index trait.
2525
///
@@ -58,14 +58,14 @@ pub trait Dimension:
5858
/// size, which you pass by reference. For the dynamic dimension it is
5959
/// a slice.
6060
///
61-
/// - For `Ix1`: `[SliceOrIndex; 1]`
62-
/// - For `Ix2`: `[SliceOrIndex; 2]`
61+
/// - For `Ix1`: `[AxisSliceInfo; 1]`
62+
/// - For `Ix2`: `[AxisSliceInfo; 2]`
6363
/// - and so on..
64-
/// - For `IxDyn`: `[SliceOrIndex]`
64+
/// - For `IxDyn`: `[AxisSliceInfo]`
6565
///
6666
/// The easiest way to create a `&SliceInfo<SliceArg, Do>` is using the
6767
/// [`s![]`](macro.s!.html) macro.
68-
type SliceArg: ?Sized + AsRef<[SliceOrIndex]>;
68+
type SliceArg: ?Sized + AsRef<[AxisSliceInfo]>;
6969
/// Pattern matching friendly form of the dimension value.
7070
///
7171
/// - For `Ix1`: `usize`,
@@ -394,7 +394,7 @@ macro_rules! impl_insert_axis_array(
394394

395395
impl Dimension for Dim<[Ix; 0]> {
396396
const NDIM: Option<usize> = Some(0);
397-
type SliceArg = [SliceOrIndex; 0];
397+
type SliceArg = [AxisSliceInfo; 0];
398398
type Pattern = ();
399399
type Smaller = Self;
400400
type Larger = Ix1;
@@ -438,7 +438,7 @@ impl Dimension for Dim<[Ix; 0]> {
438438

439439
impl Dimension for Dim<[Ix; 1]> {
440440
const NDIM: Option<usize> = Some(1);
441-
type SliceArg = [SliceOrIndex; 1];
441+
type SliceArg = [AxisSliceInfo; 1];
442442
type Pattern = Ix;
443443
type Smaller = Ix0;
444444
type Larger = Ix2;
@@ -554,7 +554,7 @@ impl Dimension for Dim<[Ix; 1]> {
554554

555555
impl Dimension for Dim<[Ix; 2]> {
556556
const NDIM: Option<usize> = Some(2);
557-
type SliceArg = [SliceOrIndex; 2];
557+
type SliceArg = [AxisSliceInfo; 2];
558558
type Pattern = (Ix, Ix);
559559
type Smaller = Ix1;
560560
type Larger = Ix3;
@@ -711,7 +711,7 @@ impl Dimension for Dim<[Ix; 2]> {
711711

712712
impl Dimension for Dim<[Ix; 3]> {
713713
const NDIM: Option<usize> = Some(3);
714-
type SliceArg = [SliceOrIndex; 3];
714+
type SliceArg = [AxisSliceInfo; 3];
715715
type Pattern = (Ix, Ix, Ix);
716716
type Smaller = Ix2;
717717
type Larger = Ix4;
@@ -834,7 +834,7 @@ macro_rules! large_dim {
834834
($n:expr, $name:ident, $pattern:ty, $larger:ty, { $($insert_axis:tt)* }) => (
835835
impl Dimension for Dim<[Ix; $n]> {
836836
const NDIM: Option<usize> = Some($n);
837-
type SliceArg = [SliceOrIndex; $n];
837+
type SliceArg = [AxisSliceInfo; $n];
838838
type Pattern = $pattern;
839839
type Smaller = Dim<[Ix; $n - 1]>;
840840
type Larger = $larger;
@@ -885,7 +885,7 @@ large_dim!(6, Ix6, (Ix, Ix, Ix, Ix, Ix, Ix), IxDyn, {
885885
/// and memory wasteful, but it allows an arbitrary and dynamic number of axes.
886886
impl Dimension for IxDyn {
887887
const NDIM: Option<usize> = None;
888-
type SliceArg = [SliceOrIndex];
888+
type SliceArg = [AxisSliceInfo];
889889
type Pattern = Self;
890890
type Smaller = Self;
891891
type Larger = Self;

src/dimension/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// except according to those terms.
88

99
use crate::error::{from_kind, ErrorKind, ShapeError};
10-
use crate::{Ix, Ixs, Slice, SliceOrIndex};
10+
use crate::{AxisSliceInfo, Ix, Ixs, Slice};
1111
use num_integer::div_floor;
1212

1313
pub use self::axes::{axes_of, Axes, AxisDescription};
@@ -599,15 +599,15 @@ pub fn slices_intersect<D: Dimension>(
599599
) -> bool {
600600
debug_assert_eq!(indices1.as_ref().len(), indices2.as_ref().len());
601601
for (&axis_len, &si1, &si2) in izip!(dim.slice(), indices1.as_ref(), indices2.as_ref()) {
602-
// The slices do not intersect iff any pair of `SliceOrIndex` does not intersect.
602+
// The slices do not intersect iff any pair of `AxisSliceInfo` does not intersect.
603603
match (si1, si2) {
604604
(
605-
SliceOrIndex::Slice {
605+
AxisSliceInfo::Slice {
606606
start: start1,
607607
end: end1,
608608
step: step1,
609609
},
610-
SliceOrIndex::Slice {
610+
AxisSliceInfo::Slice {
611611
start: start2,
612612
end: end2,
613613
step: step2,
@@ -628,8 +628,8 @@ pub fn slices_intersect<D: Dimension>(
628628
return false;
629629
}
630630
}
631-
(SliceOrIndex::Slice { start, end, step }, SliceOrIndex::Index(ind))
632-
| (SliceOrIndex::Index(ind), SliceOrIndex::Slice { start, end, step }) => {
631+
(AxisSliceInfo::Slice { start, end, step }, AxisSliceInfo::Index(ind))
632+
| (AxisSliceInfo::Index(ind), AxisSliceInfo::Slice { start, end, step }) => {
633633
let ind = abs_index(axis_len, ind);
634634
let (min, max) = match slice_min_max(axis_len, Slice::new(start, end, step)) {
635635
Some(m) => m,
@@ -639,7 +639,7 @@ pub fn slices_intersect<D: Dimension>(
639639
return false;
640640
}
641641
}
642-
(SliceOrIndex::Index(ind1), SliceOrIndex::Index(ind2)) => {
642+
(AxisSliceInfo::Index(ind1), AxisSliceInfo::Index(ind2)) => {
643643
let ind1 = abs_index(axis_len, ind1);
644644
let ind2 = abs_index(axis_len, ind2);
645645
if ind1 != ind2 {

src/impl_methods.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::iter::{
3232
};
3333
use crate::slice::MultiSlice;
3434
use crate::stacking::concatenate;
35-
use crate::{NdIndex, Slice, SliceInfo, SliceOrIndex};
35+
use crate::{AxisSliceInfo, NdIndex, Slice, SliceInfo};
3636

3737
/// # Methods For All Array Types
3838
impl<A, S, D> ArrayBase<S, D>
@@ -415,16 +415,16 @@ where
415415
// Slice and collapse in-place without changing the number of dimensions.
416416
self.slice_collapse(&*info);
417417

418-
let indices: &[SliceOrIndex] = (**info).as_ref();
418+
let indices: &[AxisSliceInfo] = (**info).as_ref();
419419

420420
// Copy the dim and strides that remain after removing the subview axes.
421421
let out_ndim = info.out_ndim();
422422
let mut new_dim = Do::zeros(out_ndim);
423423
let mut new_strides = Do::zeros(out_ndim);
424424
izip!(self.dim.slice(), self.strides.slice(), indices)
425425
.filter_map(|(d, s, slice_or_index)| match slice_or_index {
426-
SliceOrIndex::Slice { .. } => Some((d, s)),
427-
SliceOrIndex::Index(_) => None,
426+
AxisSliceInfo::Slice { .. } => Some((d, s)),
427+
AxisSliceInfo::Index(_) => None,
428428
})
429429
.zip(izip!(new_dim.slice_mut(), new_strides.slice_mut()))
430430
.for_each(|((d, s), (new_d, new_s))| {
@@ -453,16 +453,16 @@ where
453453
/// **Panics** if an index is out of bounds or step size is zero.<br>
454454
/// (**Panics** if `D` is `IxDyn` and `indices` does not match the number of array axes.)
455455
pub fn slice_collapse(&mut self, indices: &D::SliceArg) {
456-
let indices: &[SliceOrIndex] = indices.as_ref();
456+
let indices: &[AxisSliceInfo] = indices.as_ref();
457457
assert_eq!(indices.len(), self.ndim());
458458
indices
459459
.iter()
460460
.enumerate()
461461
.for_each(|(axis, &slice_or_index)| match slice_or_index {
462-
SliceOrIndex::Slice { start, end, step } => {
462+
AxisSliceInfo::Slice { start, end, step } => {
463463
self.slice_axis_inplace(Axis(axis), Slice { start, end, step })
464464
}
465-
SliceOrIndex::Index(index) => {
465+
AxisSliceInfo::Index(index) => {
466466
let i_usize = abs_index(self.len_of(Axis(axis)), index);
467467
self.collapse_axis(Axis(axis), i_usize)
468468
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub use crate::dimension::IxDynImpl;
140140
pub use crate::dimension::NdIndex;
141141
pub use crate::error::{ErrorKind, ShapeError};
142142
pub use crate::indexes::{indices, indices_of};
143-
pub use crate::slice::{Slice, SliceInfo, SliceNextDim, SliceOrIndex};
143+
pub use crate::slice::{AxisSliceInfo, Slice, SliceInfo, SliceNextDim};
144144

145145
use crate::iterators::Baseiter;
146146
use crate::iterators::{ElementsBase, ElementsBaseMut, Iter, IterMut, Lanes, LanesMut};

0 commit comments

Comments
 (0)