Skip to content

Commit c53d060

Browse files
authored
Merge pull request #945 from jturner314/rename-axissliceinfo
Rename AxisSliceInfo to SliceInfoElem
2 parents b5556f8 + 252c276 commit c53d060

File tree

7 files changed

+128
-129
lines changed

7 files changed

+128
-129
lines changed

blas-tests/tests/oper.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ 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, Slice};
10-
use ndarray::{Data, LinalgScalar};
9+
use ndarray::{Data, Ix, Ixs, LinalgScalar, Slice, SliceInfoElem};
1110

1211
use approx::{assert_abs_diff_eq, assert_relative_eq};
1312
use defmac::defmac;
@@ -419,7 +418,7 @@ fn scaled_add_3() {
419418
let mut a = range_mat64(m, k);
420419
let mut answer = a.clone();
421420
let cdim = if n == 1 { vec![q] } else { vec![n, q] };
422-
let cslice: Vec<AxisSliceInfo> = if n == 1 {
421+
let cslice: Vec<SliceInfoElem> = if n == 1 {
423422
vec![Slice::from(..).step_by(s2).into()]
424423
} else {
425424
vec![

src/dimension/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
use crate::error::{from_kind, ErrorKind, ShapeError};
1010
use crate::slice::SliceArg;
11-
use crate::{AxisSliceInfo, Ix, Ixs, Slice};
11+
use crate::{Ix, Ixs, Slice, SliceInfoElem};
1212
use num_integer::div_floor;
1313

1414
pub use self::axes::{axes_of, Axes, AxisDescription};
@@ -608,15 +608,15 @@ pub fn slices_intersect<D: Dimension>(
608608
indices1.as_ref().iter().filter(|si| !si.is_new_axis()),
609609
indices2.as_ref().iter().filter(|si| !si.is_new_axis()),
610610
) {
611-
// The slices do not intersect iff any pair of `AxisSliceInfo` does not intersect.
611+
// The slices do not intersect iff any pair of `SliceInfoElem` does not intersect.
612612
match (si1, si2) {
613613
(
614-
AxisSliceInfo::Slice {
614+
SliceInfoElem::Slice {
615615
start: start1,
616616
end: end1,
617617
step: step1,
618618
},
619-
AxisSliceInfo::Slice {
619+
SliceInfoElem::Slice {
620620
start: start2,
621621
end: end2,
622622
step: step2,
@@ -637,8 +637,8 @@ pub fn slices_intersect<D: Dimension>(
637637
return false;
638638
}
639639
}
640-
(AxisSliceInfo::Slice { start, end, step }, AxisSliceInfo::Index(ind))
641-
| (AxisSliceInfo::Index(ind), AxisSliceInfo::Slice { start, end, step }) => {
640+
(SliceInfoElem::Slice { start, end, step }, SliceInfoElem::Index(ind))
641+
| (SliceInfoElem::Index(ind), SliceInfoElem::Slice { start, end, step }) => {
642642
let ind = abs_index(axis_len, ind);
643643
let (min, max) = match slice_min_max(axis_len, Slice::new(start, end, step)) {
644644
Some(m) => m,
@@ -648,14 +648,14 @@ pub fn slices_intersect<D: Dimension>(
648648
return false;
649649
}
650650
}
651-
(AxisSliceInfo::Index(ind1), AxisSliceInfo::Index(ind2)) => {
651+
(SliceInfoElem::Index(ind1), SliceInfoElem::Index(ind2)) => {
652652
let ind1 = abs_index(axis_len, ind1);
653653
let ind2 = abs_index(axis_len, ind2);
654654
if ind1 != ind2 {
655655
return false;
656656
}
657657
}
658-
(AxisSliceInfo::NewAxis, _) | (_, AxisSliceInfo::NewAxis) => unreachable!(),
658+
(SliceInfoElem::NewAxis, _) | (_, SliceInfoElem::NewAxis) => unreachable!(),
659659
}
660660
}
661661
true

src/impl_methods.rs

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

3939
/// # Methods For All Array Types
4040
impl<A, S, D> ArrayBase<S, D>
@@ -415,7 +415,7 @@ where
415415
let mut old_axis = 0;
416416
let mut new_axis = 0;
417417
info.as_ref().iter().for_each(|&ax_info| match ax_info {
418-
AxisSliceInfo::Slice { start, end, step } => {
418+
SliceInfoElem::Slice { start, end, step } => {
419419
// Slice the axis in-place to update the `dim`, `strides`, and `ptr`.
420420
self.slice_axis_inplace(Axis(old_axis), Slice { start, end, step });
421421
// Copy the sliced dim and stride to corresponding axis.
@@ -424,7 +424,7 @@ where
424424
old_axis += 1;
425425
new_axis += 1;
426426
}
427-
AxisSliceInfo::Index(index) => {
427+
SliceInfoElem::Index(index) => {
428428
// Collapse the axis in-place to update the `ptr`.
429429
let i_usize = abs_index(self.len_of(Axis(old_axis)), index);
430430
self.collapse_axis(Axis(old_axis), i_usize);
@@ -434,7 +434,7 @@ where
434434
// is zero length.
435435
old_axis += 1;
436436
}
437-
AxisSliceInfo::NewAxis => {
437+
SliceInfoElem::NewAxis => {
438438
// Set the dim and stride of the new axis.
439439
new_dim[new_axis] = 1;
440440
new_strides[new_axis] = 0;
@@ -465,7 +465,7 @@ where
465465
///
466466
/// - if an index is out of bounds
467467
/// - if a step size is zero
468-
/// - if [`AxisSliceInfo::NewAxis`] is in `info`, e.g. if [`NewAxis`] was
468+
/// - if [`SliceInfoElem::NewAxis`] is in `info`, e.g. if [`NewAxis`] was
469469
/// used in the [`s!`] macro
470470
/// - if `D` is `IxDyn` and `info` does not match the number of array axes
471471
pub fn slice_collapse<I>(&mut self, info: I)
@@ -479,16 +479,16 @@ where
479479
);
480480
let mut axis = 0;
481481
info.as_ref().iter().for_each(|&ax_info| match ax_info {
482-
AxisSliceInfo::Slice { start, end, step } => {
482+
SliceInfoElem::Slice { start, end, step } => {
483483
self.slice_axis_inplace(Axis(axis), Slice { start, end, step });
484484
axis += 1;
485485
}
486-
AxisSliceInfo::Index(index) => {
486+
SliceInfoElem::Index(index) => {
487487
let i_usize = abs_index(self.len_of(Axis(axis)), index);
488488
self.collapse_axis(Axis(axis), i_usize);
489489
axis += 1;
490490
}
491-
AxisSliceInfo::NewAxis => panic!("`slice_collapse` does not support `NewAxis`."),
491+
SliceInfoElem::NewAxis => panic!("`slice_collapse` does not support `NewAxis`."),
492492
});
493493
debug_assert_eq!(axis, self.ndim());
494494
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ pub use crate::dimension::NdIndex;
144144
pub use crate::error::{ErrorKind, ShapeError};
145145
pub use crate::indexes::{indices, indices_of};
146146
pub use crate::slice::{
147-
AxisSliceInfo, MultiSliceArg, NewAxis, Slice, SliceArg, SliceInfo, SliceNextDim,
147+
MultiSliceArg, NewAxis, Slice, SliceArg, SliceInfo, SliceInfoElem, SliceNextDim,
148148
};
149149

150150
use crate::iterators::Baseiter;

0 commit comments

Comments
 (0)