stack¶
- stack(arrays: Tuple[array, ...] | List[array], /, *, axis: int = 0) array ¶
Joins a sequence of arrays along a new axis.
- Parameters:
arrays (Union[Tuple[array, ...], List[array]]) – input arrays to join. Each array must have the same shape.
axis (int) – axis along which the arrays will be joined. Providing an
axis
specifies the index of the new axis in the dimensions of the result. For example, ifaxis
is0
, the new axis will be the first dimension and the output array will have shape(N, A, B, C)
; ifaxis
is1
, the new axis will be the second dimension and the output array will have shape(A, N, B, C)
; and, ifaxis
is-1
, the new axis will be the last dimension and the output array will have shape(A, B, C, N)
. A validaxis
must be on the interval[-N, N)
, whereN
is the rank (number of dimensions) ofx
. If provided anaxis
outside of the required interval, the function must raise an exception. Default:0
.
- Returns:
out (array) – an output array having rank
N+1
, whereN
is the rank (number of dimensions) ofx
. If the input arrays have different data types, normal Type Promotion Rules must apply. If the input arrays have the same data type, the output array must have the same data type as the input arrays.Note
This specification leaves type promotion between data type families (i.e.,
intxx
andfloatxx
) unspecified.