@@ -310,7 +310,7 @@ impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
310
310
where
311
311
Do : Dimension ,
312
312
{
313
- // Slice and subview in-place without changing the number of dimensions.
313
+ // Slice and collapse in-place without changing the number of dimensions.
314
314
self . slice_inplace ( & * info) ;
315
315
316
316
let indices: & [ SliceOrIndex ] = ( * * info) . as_ref ( ) ;
@@ -364,7 +364,7 @@ impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
364
364
}
365
365
& SliceOrIndex :: Index ( index) => {
366
366
let i_usize = abs_index ( self . len_of ( Axis ( axis) ) , index) ;
367
- self . subview_inplace ( Axis ( axis) , i_usize)
367
+ self . collapse_axis ( Axis ( axis) , i_usize)
368
368
}
369
369
} ) ;
370
370
}
@@ -542,6 +542,15 @@ impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
542
542
}
543
543
}
544
544
545
+ /// Collapse the axis into length one, selecting the subview at the given
546
+ /// `index` along the axis.
547
+ ///
548
+ /// **Panics** if `index` is past the length of the axis.
549
+ pub fn collapse_axis ( & mut self , axis : Axis , index : usize ) {
550
+ dimension:: do_sub ( & mut self . dim , & mut self . ptr , & self . strides ,
551
+ axis. index ( ) , index)
552
+ }
553
+
545
554
/// Along `axis`, select the subview `index` and return a
546
555
/// view with that axis removed.
547
556
///
@@ -605,9 +614,9 @@ impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
605
614
/// and select the subview of `index` along that axis.
606
615
///
607
616
/// **Panics** if `index` is past the length of the axis.
617
+ #[ deprecated( note="renamed to `collapse_axis`" , since="0.12.1" ) ]
608
618
pub fn subview_inplace ( & mut self , axis : Axis , index : Ix ) {
609
- dimension:: do_sub ( & mut self . dim , & mut self . ptr , & self . strides ,
610
- axis. index ( ) , index)
619
+ self . collapse_axis ( axis, index)
611
620
}
612
621
613
622
/// Along `axis`, select the subview `index` and return `self`
@@ -617,7 +626,7 @@ impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
617
626
pub fn into_subview ( mut self , axis : Axis , index : Ix ) -> ArrayBase < S , D :: Smaller >
618
627
where D : RemoveAxis ,
619
628
{
620
- self . subview_inplace ( axis, index) ;
629
+ self . collapse_axis ( axis, index) ;
621
630
self . remove_axis ( axis)
622
631
}
623
632
@@ -648,7 +657,7 @@ impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
648
657
{
649
658
let mut subs = vec ! [ self . view( ) ; indices. len( ) ] ;
650
659
for ( & i, sub) in zip ( indices, & mut subs[ ..] ) {
651
- sub. subview_inplace ( axis, i) ;
660
+ sub. collapse_axis ( axis, i) ;
652
661
}
653
662
if subs. is_empty ( ) {
654
663
let mut dim = self . raw_dim ( ) ;
0 commit comments