Skip to content

Commit 050c5f5

Browse files
committed
Rename SliceOrIndex to AxisSliceInfo
1 parent 27c84a5 commit 050c5f5

File tree

8 files changed

+108
-108
lines changed

8 files changed

+108
-108
lines changed

blas-tests/tests/oper.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use ndarray::prelude::*;
66
use ndarray::{LinalgScalar, Data};
77
use ndarray::linalg::general_mat_mul;
88
use ndarray::linalg::general_mat_vec_mul;
9-
use ndarray::{Ix, Ixs, SliceInfo, SliceOrIndex};
9+
use ndarray::{Ix, Ixs, SliceInfo, AxisSliceInfo};
1010

1111
use std::fmt;
1212
use defmac::defmac;
@@ -433,11 +433,11 @@ fn scaled_add_3() {
433433
vec![n, q]
434434
};
435435
let cslice = if n == 1 {
436-
vec![SliceOrIndex::from(..).step_by(s2)]
436+
vec![AxisSliceInfo::from(..).step_by(s2)]
437437
} else {
438438
vec![
439-
SliceOrIndex::from(..).step_by(s1),
440-
SliceOrIndex::from(..).step_by(s2),
439+
AxisSliceInfo::from(..).step_by(s1),
440+
AxisSliceInfo::from(..).step_by(s2),
441441
]
442442
};
443443

src/dimension/dimension_trait.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::ops::{Add, Sub, Mul, AddAssign, SubAssign, MulAssign};
1313

1414
use itertools::{enumerate, izip, zip};
1515

16-
use crate::{Ix, Ixs, Ix0, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn, Dim, SliceOrIndex, IxDynImpl};
16+
use crate::{Ix, Ixs, Ix0, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn, Dim, AxisSliceInfo, IxDynImpl};
1717
use crate::IntoDimension;
1818
use crate::RemoveAxis;
1919
use crate::{ArrayView1, ArrayViewMut1};
@@ -52,14 +52,14 @@ pub trait Dimension : Clone + Eq + Debug + Send + Sync + Default +
5252
/// size, which you pass by reference. For the dynamic dimension it is
5353
/// a slice.
5454
///
55-
/// - For `Ix1`: `[SliceOrIndex; 1]`
56-
/// - For `Ix2`: `[SliceOrIndex; 2]`
55+
/// - For `Ix1`: `[AxisSliceInfo; 1]`
56+
/// - For `Ix2`: `[AxisSliceInfo; 2]`
5757
/// - and so on..
58-
/// - For `IxDyn`: `[SliceOrIndex]`
58+
/// - For `IxDyn`: `[AxisSliceInfo]`
5959
///
6060
/// The easiest way to create a `&SliceInfo<SliceArg, Do>` is using the
6161
/// [`s![]`](macro.s!.html) macro.
62-
type SliceArg: ?Sized + AsRef<[SliceOrIndex]>;
62+
type SliceArg: ?Sized + AsRef<[AxisSliceInfo]>;
6363
/// Pattern matching friendly form of the dimension value.
6464
///
6565
/// - For `Ix1`: `usize`,
@@ -364,7 +364,7 @@ macro_rules! impl_insert_axis_array(
364364

365365
impl Dimension for Dim<[Ix; 0]> {
366366
const NDIM: Option<usize> = Some(0);
367-
type SliceArg = [SliceOrIndex; 0];
367+
type SliceArg = [AxisSliceInfo; 0];
368368
type Pattern = ();
369369
type Smaller = Self;
370370
type Larger = Ix1;
@@ -401,7 +401,7 @@ impl Dimension for Dim<[Ix; 0]> {
401401

402402
impl Dimension for Dim<[Ix; 1]> {
403403
const NDIM: Option<usize> = Some(1);
404-
type SliceArg = [SliceOrIndex; 1];
404+
type SliceArg = [AxisSliceInfo; 1];
405405
type Pattern = Ix;
406406
type Smaller = Ix0;
407407
type Larger = Ix2;
@@ -499,7 +499,7 @@ impl Dimension for Dim<[Ix; 1]> {
499499

500500
impl Dimension for Dim<[Ix; 2]> {
501501
const NDIM: Option<usize> = Some(2);
502-
type SliceArg = [SliceOrIndex; 2];
502+
type SliceArg = [AxisSliceInfo; 2];
503503
type Pattern = (Ix, Ix);
504504
type Smaller = Ix1;
505505
type Larger = Ix3;
@@ -645,7 +645,7 @@ impl Dimension for Dim<[Ix; 2]> {
645645

646646
impl Dimension for Dim<[Ix; 3]> {
647647
const NDIM: Option<usize> = Some(3);
648-
type SliceArg = [SliceOrIndex; 3];
648+
type SliceArg = [AxisSliceInfo; 3];
649649
type Pattern = (Ix, Ix, Ix);
650650
type Smaller = Ix2;
651651
type Larger = Ix4;
@@ -763,7 +763,7 @@ macro_rules! large_dim {
763763
($n:expr, $name:ident, $pattern:ty, $larger:ty, { $($insert_axis:tt)* }) => (
764764
impl Dimension for Dim<[Ix; $n]> {
765765
const NDIM: Option<usize> = Some($n);
766-
type SliceArg = [SliceOrIndex; $n];
766+
type SliceArg = [AxisSliceInfo; $n];
767767
type Pattern = $pattern;
768768
type Smaller = Dim<[Ix; $n - 1]>;
769769
type Larger = $larger;
@@ -815,7 +815,7 @@ large_dim!(6, Ix6, (Ix, Ix, Ix, Ix, Ix, Ix), IxDyn, {
815815
impl Dimension for IxDyn
816816
{
817817
const NDIM: Option<usize> = None;
818-
type SliceArg = [SliceOrIndex];
818+
type SliceArg = [AxisSliceInfo];
819819
type Pattern = Self;
820820
type Smaller = Self;
821821
type Larger = Self;

src/dimension/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
88

9-
use crate::{Ix, Ixs, Slice, SliceOrIndex};
9+
use crate::{AxisSliceInfo, Ix, Ixs, Slice};
1010
use crate::error::{from_kind, ErrorKind, ShapeError};
1111
use itertools::izip;
1212
use num_integer::div_floor;
@@ -534,15 +534,15 @@ pub fn slices_intersect<D: Dimension>(
534534
) -> bool {
535535
debug_assert_eq!(indices1.as_ref().len(), indices2.as_ref().len());
536536
for (&axis_len, &si1, &si2) in izip!(dim.slice(), indices1.as_ref(), indices2.as_ref()) {
537-
// The slices do not intersect iff any pair of `SliceOrIndex` does not intersect.
537+
// The slices do not intersect iff any pair of `AxisSliceInfo` does not intersect.
538538
match (si1, si2) {
539539
(
540-
SliceOrIndex::Slice {
540+
AxisSliceInfo::Slice {
541541
start: start1,
542542
end: end1,
543543
step: step1,
544544
},
545-
SliceOrIndex::Slice {
545+
AxisSliceInfo::Slice {
546546
start: start2,
547547
end: end2,
548548
step: step2,
@@ -563,8 +563,8 @@ pub fn slices_intersect<D: Dimension>(
563563
return false;
564564
}
565565
}
566-
(SliceOrIndex::Slice { start, end, step }, SliceOrIndex::Index(ind)) |
567-
(SliceOrIndex::Index(ind), SliceOrIndex::Slice { start, end, step }) => {
566+
(AxisSliceInfo::Slice { start, end, step }, AxisSliceInfo::Index(ind)) |
567+
(AxisSliceInfo::Index(ind), AxisSliceInfo::Slice { start, end, step }) => {
568568
let ind = abs_index(axis_len, ind);
569569
let (min, max) = match slice_min_max(axis_len, Slice::new(start, end, step)) {
570570
Some(m) => m,
@@ -574,7 +574,7 @@ pub fn slices_intersect<D: Dimension>(
574574
return false;
575575
}
576576
}
577-
(SliceOrIndex::Index(ind1), SliceOrIndex::Index(ind2)) => {
577+
(AxisSliceInfo::Index(ind1), AxisSliceInfo::Index(ind2)) => {
578578
let ind1 = abs_index(axis_len, ind1);
579579
let ind2 = abs_index(axis_len, ind2);
580580
if ind1 != ind2 {

src/impl_methods.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ use crate::dimension::{abs_index, axes_of, Axes, do_slice, merge_axes, size_of_s
2222
use crate::zip::Zip;
2323

2424
use crate::{
25+
AxisSliceInfo,
2526
NdIndex,
2627
Slice,
2728
SliceInfo,
28-
SliceOrIndex
2929
};
3030
use crate::iter::{
3131
AxisChunksIter,
@@ -346,16 +346,16 @@ where
346346
// Slice and collapse in-place without changing the number of dimensions.
347347
self.slice_collapse(&*info);
348348

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

351351
// Copy the dim and strides that remain after removing the subview axes.
352352
let out_ndim = info.out_ndim();
353353
let mut new_dim = Do::zeros(out_ndim);
354354
let mut new_strides = Do::zeros(out_ndim);
355355
izip!(self.dim.slice(), self.strides.slice(), indices)
356356
.filter_map(|(d, s, slice_or_index)| match slice_or_index {
357-
&SliceOrIndex::Slice {..} => Some((d, s)),
358-
&SliceOrIndex::Index(_) => None,
357+
&AxisSliceInfo::Slice {..} => Some((d, s)),
358+
&AxisSliceInfo::Index(_) => None,
359359
})
360360
.zip(izip!(new_dim.slice_mut(), new_strides.slice_mut()))
361361
.for_each(|((d, s), (new_d, new_s))| {
@@ -386,16 +386,16 @@ where
386386
/// **Panics** if an index is out of bounds or step size is zero.<br>
387387
/// (**Panics** if `D` is `IxDyn` and `indices` does not match the number of array axes.)
388388
pub fn slice_collapse(&mut self, indices: &D::SliceArg) {
389-
let indices: &[SliceOrIndex] = indices.as_ref();
389+
let indices: &[AxisSliceInfo] = indices.as_ref();
390390
assert_eq!(indices.len(), self.ndim());
391391
indices
392392
.iter()
393393
.enumerate()
394394
.for_each(|(axis, slice_or_index)| match slice_or_index {
395-
&SliceOrIndex::Slice { start, end, step } => {
395+
&AxisSliceInfo::Slice { start, end, step } => {
396396
self.slice_axis_inplace(Axis(axis), Slice { start, end, step })
397397
}
398-
&SliceOrIndex::Index(index) => {
398+
&AxisSliceInfo::Index(index) => {
399399
let i_usize = abs_index(self.len_of(Axis(axis)), index);
400400
self.collapse_axis(Axis(axis), i_usize)
401401
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub use crate::indexes::{indices, indices_of};
127127
pub use crate::error::{ShapeError, ErrorKind};
128128
pub use crate::slice::{
129129
deref_raw_view_mut_into_view_with_life, deref_raw_view_mut_into_view_mut_with_life,
130-
life_of_view_mut, Slice, SliceInfo, SliceNextDim, SliceOrIndex
130+
life_of_view_mut, AxisSliceInfo, Slice, SliceInfo, SliceNextDim,
131131
};
132132

133133
use crate::iterators::Baseiter;

0 commit comments

Comments
 (0)