Skip to content

Commit 24a3299

Browse files
jturner314bluss
authored andcommitted
Rename SliceOrIndex to AxisSliceInfo
1 parent 9b23ba5 commit 24a3299

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

1212
use approx::{assert_abs_diff_eq, assert_relative_eq};
1313
use defmac::defmac;
@@ -420,11 +420,11 @@ fn scaled_add_3() {
420420
let mut answer = a.clone();
421421
let cdim = if n == 1 { vec![q] } else { vec![n, q] };
422422
let cslice = if n == 1 {
423-
vec![SliceOrIndex::from(..).step_by(s2)]
423+
vec![AxisSliceInfo::from(..).step_by(s2)]
424424
} else {
425425
vec![
426-
SliceOrIndex::from(..).step_by(s1),
427-
SliceOrIndex::from(..).step_by(s2),
426+
AxisSliceInfo::from(..).step_by(s1),
427+
AxisSliceInfo::from(..).step_by(s2),
428428
]
429429
};
430430

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, DimMax};
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
///
@@ -63,14 +63,14 @@ pub trait Dimension:
6363
/// size, which you pass by reference. For the dynamic dimension it is
6464
/// a slice.
6565
///
66-
/// - For `Ix1`: `[SliceOrIndex; 1]`
67-
/// - For `Ix2`: `[SliceOrIndex; 2]`
66+
/// - For `Ix1`: `[AxisSliceInfo; 1]`
67+
/// - For `Ix2`: `[AxisSliceInfo; 2]`
6868
/// - and so on..
69-
/// - For `IxDyn`: `[SliceOrIndex]`
69+
/// - For `IxDyn`: `[AxisSliceInfo]`
7070
///
7171
/// The easiest way to create a `&SliceInfo<SliceArg, Do>` is using the
7272
/// [`s![]`](macro.s!.html) macro.
73-
type SliceArg: ?Sized + AsRef<[SliceOrIndex]>;
73+
type SliceArg: ?Sized + AsRef<[AxisSliceInfo]>;
7474
/// Pattern matching friendly form of the dimension value.
7575
///
7676
/// - For `Ix1`: `usize`,
@@ -399,7 +399,7 @@ macro_rules! impl_insert_axis_array(
399399

400400
impl Dimension for Dim<[Ix; 0]> {
401401
const NDIM: Option<usize> = Some(0);
402-
type SliceArg = [SliceOrIndex; 0];
402+
type SliceArg = [AxisSliceInfo; 0];
403403
type Pattern = ();
404404
type Smaller = Self;
405405
type Larger = Ix1;
@@ -443,7 +443,7 @@ impl Dimension for Dim<[Ix; 0]> {
443443

444444
impl Dimension for Dim<[Ix; 1]> {
445445
const NDIM: Option<usize> = Some(1);
446-
type SliceArg = [SliceOrIndex; 1];
446+
type SliceArg = [AxisSliceInfo; 1];
447447
type Pattern = Ix;
448448
type Smaller = Ix0;
449449
type Larger = Ix2;
@@ -559,7 +559,7 @@ impl Dimension for Dim<[Ix; 1]> {
559559

560560
impl Dimension for Dim<[Ix; 2]> {
561561
const NDIM: Option<usize> = Some(2);
562-
type SliceArg = [SliceOrIndex; 2];
562+
type SliceArg = [AxisSliceInfo; 2];
563563
type Pattern = (Ix, Ix);
564564
type Smaller = Ix1;
565565
type Larger = Ix3;
@@ -716,7 +716,7 @@ impl Dimension for Dim<[Ix; 2]> {
716716

717717
impl Dimension for Dim<[Ix; 3]> {
718718
const NDIM: Option<usize> = Some(3);
719-
type SliceArg = [SliceOrIndex; 3];
719+
type SliceArg = [AxisSliceInfo; 3];
720720
type Pattern = (Ix, Ix, Ix);
721721
type Smaller = Ix2;
722722
type Larger = Ix4;
@@ -839,7 +839,7 @@ macro_rules! large_dim {
839839
($n:expr, $name:ident, $pattern:ty, $larger:ty, { $($insert_axis:tt)* }) => (
840840
impl Dimension for Dim<[Ix; $n]> {
841841
const NDIM: Option<usize> = Some($n);
842-
type SliceArg = [SliceOrIndex; $n];
842+
type SliceArg = [AxisSliceInfo; $n];
843843
type Pattern = $pattern;
844844
type Smaller = Dim<[Ix; $n - 1]>;
845845
type Larger = $larger;
@@ -890,7 +890,7 @@ large_dim!(6, Ix6, (Ix, Ix, Ix, Ix, Ix, Ix), IxDyn, {
890890
/// and memory wasteful, but it allows an arbitrary and dynamic number of axes.
891891
impl Dimension for IxDyn {
892892
const NDIM: Option<usize> = None;
893-
type SliceArg = [SliceOrIndex];
893+
type SliceArg = [AxisSliceInfo];
894894
type Pattern = Self;
895895
type Smaller = Self;
896896
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};
@@ -601,15 +601,15 @@ pub fn slices_intersect<D: Dimension>(
601601
) -> bool {
602602
debug_assert_eq!(indices1.as_ref().len(), indices2.as_ref().len());
603603
for (&axis_len, &si1, &si2) in izip!(dim.slice(), indices1.as_ref(), indices2.as_ref()) {
604-
// The slices do not intersect iff any pair of `SliceOrIndex` does not intersect.
604+
// The slices do not intersect iff any pair of `AxisSliceInfo` does not intersect.
605605
match (si1, si2) {
606606
(
607-
SliceOrIndex::Slice {
607+
AxisSliceInfo::Slice {
608608
start: start1,
609609
end: end1,
610610
step: step1,
611611
},
612-
SliceOrIndex::Slice {
612+
AxisSliceInfo::Slice {
613613
start: start2,
614614
end: end2,
615615
step: step2,
@@ -630,8 +630,8 @@ pub fn slices_intersect<D: Dimension>(
630630
return false;
631631
}
632632
}
633-
(SliceOrIndex::Slice { start, end, step }, SliceOrIndex::Index(ind))
634-
| (SliceOrIndex::Index(ind), SliceOrIndex::Slice { start, end, step }) => {
633+
(AxisSliceInfo::Slice { start, end, step }, AxisSliceInfo::Index(ind))
634+
| (AxisSliceInfo::Index(ind), AxisSliceInfo::Slice { start, end, step }) => {
635635
let ind = abs_index(axis_len, ind);
636636
let (min, max) = match slice_min_max(axis_len, Slice::new(start, end, step)) {
637637
Some(m) => m,
@@ -641,7 +641,7 @@ pub fn slices_intersect<D: Dimension>(
641641
return false;
642642
}
643643
}
644-
(SliceOrIndex::Index(ind1), SliceOrIndex::Index(ind2)) => {
644+
(AxisSliceInfo::Index(ind1), AxisSliceInfo::Index(ind2)) => {
645645
let ind1 = abs_index(axis_len, ind1);
646646
let ind2 = abs_index(axis_len, ind2);
647647
if ind1 != ind2 {

src/impl_methods.rs

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

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

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

422422
// Copy the dim and strides that remain after removing the subview axes.
423423
let out_ndim = info.out_ndim();
424424
let mut new_dim = Do::zeros(out_ndim);
425425
let mut new_strides = Do::zeros(out_ndim);
426426
izip!(self.dim.slice(), self.strides.slice(), indices)
427427
.filter_map(|(d, s, slice_or_index)| match slice_or_index {
428-
SliceOrIndex::Slice { .. } => Some((d, s)),
429-
SliceOrIndex::Index(_) => None,
428+
AxisSliceInfo::Slice { .. } => Some((d, s)),
429+
AxisSliceInfo::Index(_) => None,
430430
})
431431
.zip(izip!(new_dim.slice_mut(), new_strides.slice_mut()))
432432
.for_each(|((d, s), (new_d, new_s))| {
@@ -455,16 +455,16 @@ where
455455
/// **Panics** if an index is out of bounds or step size is zero.<br>
456456
/// (**Panics** if `D` is `IxDyn` and `indices` does not match the number of array axes.)
457457
pub fn slice_collapse(&mut self, indices: &D::SliceArg) {
458-
let indices: &[SliceOrIndex] = indices.as_ref();
458+
let indices: &[AxisSliceInfo] = indices.as_ref();
459459
assert_eq!(indices.len(), self.ndim());
460460
indices
461461
.iter()
462462
.enumerate()
463463
.for_each(|(axis, &slice_or_index)| match slice_or_index {
464-
SliceOrIndex::Slice { start, end, step } => {
464+
AxisSliceInfo::Slice { start, end, step } => {
465465
self.slice_axis_inplace(Axis(axis), Slice { start, end, step })
466466
}
467-
SliceOrIndex::Index(index) => {
467+
AxisSliceInfo::Index(index) => {
468468
let i_usize = abs_index(self.len_of(Axis(axis)), index);
469469
self.collapse_axis(Axis(axis), i_usize)
470470
}

src/lib.rs

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

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

0 commit comments

Comments
 (0)