9
9
use crate :: error:: { from_kind, ErrorKind , ShapeError } ;
10
10
use crate :: imp_prelude:: * ;
11
11
12
+ /// Stack arrays along the new axis.
13
+ ///
14
+ /// ***Errors*** if the arrays have mismatching shapes.
15
+ /// ***Errors*** if `arrays` is empty, if `axis` is out of bounds,
16
+ /// if the result is larger than is possible to represent.
17
+ ///
18
+ /// ```
19
+ /// extern crate ndarray;
20
+ ///
21
+ /// use ndarray::{arr2, arr3, stack, Axis};
22
+ ///
23
+ /// # fn main() {
24
+ ///
25
+ /// let a = arr2(&[[2., 2.],
26
+ /// [3., 3.]]);
27
+ /// assert!(
28
+ /// stack(Axis(0), &[a.view(), a.view()])
29
+ /// == Ok(arr3(&[[[2., 2.],
30
+ /// [3., 3.]],
31
+ /// [[2., 2.],
32
+ /// [3., 3.]]]))
33
+ /// );
34
+ /// # }
35
+ /// ```
36
+ pub fn stack < A , D > (
37
+ axis : Axis ,
38
+ arrays : & [ ArrayView < A , D > ] ,
39
+ ) -> Result < Array < A , D :: Larger > , ShapeError >
40
+ where
41
+ A : Copy ,
42
+ D : Dimension ,
43
+ D :: Larger : RemoveAxis ,
44
+ {
45
+ stack_new_axis ( axis, arrays)
46
+ }
47
+
12
48
/// Concatenate arrays along the given axis.
13
49
///
14
50
/// ***Errors*** if the arrays have mismatching shapes, apart from along `axis`.
@@ -17,23 +53,20 @@ use crate::imp_prelude::*;
17
53
/// if the result is larger than is possible to represent.
18
54
///
19
55
/// ```
20
- /// use ndarray::{arr2, Axis, stack };
56
+ /// use ndarray::{arr2, Axis, concatenate };
21
57
///
22
58
/// let a = arr2(&[[2., 2.],
23
59
/// [3., 3.]]);
24
60
/// assert!(
25
- /// stack (Axis(0), &[a.view(), a.view()])
61
+ /// concatenate (Axis(0), &[a.view(), a.view()])
26
62
/// == Ok(arr2(&[[2., 2.],
27
63
/// [3., 3.],
28
64
/// [2., 2.],
29
65
/// [3., 3.]]))
30
66
/// );
31
67
/// ```
32
- #[ deprecated(
33
- since = "0.13.2" ,
34
- note = "Please use the `concatenate` function instead"
35
- ) ]
36
- pub fn stack < A , D > ( axis : Axis , arrays : & [ ArrayView < A , D > ] ) -> Result < Array < A , D > , ShapeError >
68
+ #[ allow( deprecated) ]
69
+ pub fn concatenate < A , D > ( axis : Axis , arrays : & [ ArrayView < A , D > ] ) -> Result < Array < A , D > , ShapeError >
37
70
where
38
71
A : Copy ,
39
72
D : RemoveAxis ,
@@ -77,35 +110,6 @@ where
77
110
Ok ( res)
78
111
}
79
112
80
- /// Concatenate arrays along the given axis.
81
- ///
82
- /// ***Errors*** if the arrays have mismatching shapes, apart from along `axis`.
83
- /// (may be made more flexible in the future).<br>
84
- /// ***Errors*** if `arrays` is empty, if `axis` is out of bounds,
85
- /// if the result is larger than is possible to represent.
86
- ///
87
- /// ```
88
- /// use ndarray::{arr2, Axis, concatenate};
89
- ///
90
- /// let a = arr2(&[[2., 2.],
91
- /// [3., 3.]]);
92
- /// assert!(
93
- /// concatenate(Axis(0), &[a.view(), a.view()])
94
- /// == Ok(arr2(&[[2., 2.],
95
- /// [3., 3.],
96
- /// [2., 2.],
97
- /// [3., 3.]]))
98
- /// );
99
- /// ```
100
- #[ allow( deprecated) ]
101
- pub fn concatenate < A , D > ( axis : Axis , arrays : & [ ArrayView < A , D > ] ) -> Result < Array < A , D > , ShapeError >
102
- where
103
- A : Copy ,
104
- D : RemoveAxis ,
105
- {
106
- stack ( axis, arrays)
107
- }
108
-
109
113
/// Stack arrays along the new axis.
110
114
///
111
115
/// ***Errors*** if the arrays have mismatching shapes.
@@ -173,7 +177,7 @@ where
173
177
Ok ( res)
174
178
}
175
179
176
- /// Concatenate arrays along the given axis.
180
+ /// Stack arrays along the new axis.
177
181
///
178
182
/// Uses the [`stack`][1] function, calling `ArrayView::from(&a)` on each
179
183
/// argument `a`.
@@ -183,25 +187,23 @@ where
183
187
/// ***Panics*** if the `stack` function would return an error.
184
188
///
185
189
/// ```
186
- /// use ndarray::{arr2, stack, Axis};
190
+ /// extern crate ndarray;
191
+ ///
192
+ /// use ndarray::{arr2, arr3, stack, Axis};
187
193
///
188
194
/// # fn main() {
189
195
///
190
196
/// let a = arr2(&[[2., 2.],
191
197
/// [3., 3.]]);
192
198
/// assert!(
193
199
/// stack![Axis(0), a, a]
194
- /// == arr2(& [[2., 2.],
195
- /// [3., 3.],
196
- /// [2., 2.],
197
- /// [3., 3.]])
200
+ /// == arr3(&[ [[2., 2.],
201
+ /// [3., 3.] ],
202
+ /// [[ 2., 2.],
203
+ /// [3., 3.] ]])
198
204
/// );
199
205
/// # }
200
206
/// ```
201
- #[ deprecated(
202
- since = "0.13.2" ,
203
- note = "Please use the `concatenate!` macro instead"
204
- ) ]
205
207
#[ macro_export]
206
208
macro_rules! stack {
207
209
( $axis: expr, $( $array: expr ) ,+ ) => {
0 commit comments