@@ -30,7 +30,7 @@ use crate::imp_prelude::*;
3030/// );
3131/// ```
3232#[ deprecated(
33- since = "0.13.1 " ,
33+ since = "0.13.2 " ,
3434 note = "Please use the `concatenate` function instead"
3535) ]
3636pub fn stack < A , D > ( axis : Axis , arrays : & [ ArrayView < A , D > ] ) -> Result < Array < A , D > , ShapeError >
@@ -106,9 +106,33 @@ where
106106 stack ( axis, arrays)
107107}
108108
109+ /// Stack arrays along the new axis.
110+ ///
111+ /// ***Errors*** if the arrays have mismatching shapes.
112+ /// ***Errors*** if `arrays` is empty, if `axis` is out of bounds,
113+ /// if the result is larger than is possible to represent.
114+ ///
115+ /// ```
116+ /// extern crate ndarray;
117+ ///
118+ /// use ndarray::{arr2, arr3, stack_new_axis, Axis};
119+ ///
120+ /// # fn main() {
121+ ///
122+ /// let a = arr2(&[[2., 2.],
123+ /// [3., 3.]]);
124+ /// assert!(
125+ /// stack_new_axis(Axis(0), &[a.view(), a.view()])
126+ /// == Ok(arr3(&[[[2., 2.],
127+ /// [3., 3.]],
128+ /// [[2., 2.],
129+ /// [3., 3.]]]))
130+ /// );
131+ /// # }
132+ /// ```
109133pub fn stack_new_axis < A , D > (
110134 axis : Axis ,
111- arrays : Vec < ArrayView < A , D > > ,
135+ arrays : & [ ArrayView < A , D > ] ,
112136) -> Result < Array < A , D :: Larger > , ShapeError >
113137where
114138 A : Copy ,
@@ -176,6 +200,10 @@ where
176200/// );
177201/// # }
178202/// ```
203+ #[ deprecated(
204+ since = "0.13.2" ,
205+ note = "Please use the `concatenate!` macro instead"
206+ ) ]
179207#[ macro_export]
180208macro_rules! stack {
181209 ( $axis: expr, $( $array: expr ) ,+ ) => {
@@ -247,6 +275,6 @@ macro_rules! concatenate {
247275#[ macro_export]
248276macro_rules! stack_new_axis {
249277 ( $axis: expr, $( $array: expr ) ,+ ) => {
250- $crate:: stack_new_axis( $axis, vec! [ $( $crate:: ArrayView :: from( & $array) ) ,* ] ) . unwrap( )
278+ $crate:: stack_new_axis( $axis, & [ $( $crate:: ArrayView :: from( & $array) ) ,* ] ) . unwrap( )
251279 }
252280}
0 commit comments