@@ -30,7 +30,7 @@ use crate::imp_prelude::*;
30
30
/// );
31
31
/// ```
32
32
#[ deprecated(
33
- since = "0.13.1 " ,
33
+ since = "0.13.2 " ,
34
34
note = "Please use the `concatenate` function instead"
35
35
) ]
36
36
pub fn stack < A , D > ( axis : Axis , arrays : & [ ArrayView < A , D > ] ) -> Result < Array < A , D > , ShapeError >
@@ -106,9 +106,33 @@ where
106
106
stack ( axis, arrays)
107
107
}
108
108
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
+ /// ```
109
133
pub fn stack_new_axis < A , D > (
110
134
axis : Axis ,
111
- arrays : Vec < ArrayView < A , D > > ,
135
+ arrays : & [ ArrayView < A , D > ] ,
112
136
) -> Result < Array < A , D :: Larger > , ShapeError >
113
137
where
114
138
A : Copy ,
@@ -176,6 +200,10 @@ where
176
200
/// );
177
201
/// # }
178
202
/// ```
203
+ #[ deprecated(
204
+ since = "0.13.2" ,
205
+ note = "Please use the `concatenate!` macro instead"
206
+ ) ]
179
207
#[ macro_export]
180
208
macro_rules! stack {
181
209
( $axis: expr, $( $array: expr ) ,+ ) => {
@@ -247,6 +275,6 @@ macro_rules! concatenate {
247
275
#[ macro_export]
248
276
macro_rules! stack_new_axis {
249
277
( $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( )
251
279
}
252
280
}
0 commit comments