expand_dims¶
- expand_dims(x: array, /, *, axis: int = 0) array¶
Expands the shape of an array by inserting a new axis (dimension) of size one at the position specified by
axis.- Parameters:
x (array) – input array.
axis (int) – axis position (zero-based). If
xhas rank (i.e, number of dimensions)N, a validaxismust reside on the closed-interval[-N-1, N]. If provided a negativeaxis, the axis position at which to insert a singleton dimension must be computed asN + axis + 1. Hence, if provided-1, the resolved axis position must beN(i.e., a singleton dimension must be appended to the input arrayx). If provided-N-1, the resolved axis position must be0(i.e., a singleton dimension must be prepended to the input arrayx).
- Returns:
out (array) – an expanded output array having the same data type as
x.- Raises:
IndexError – If provided an invalid
axisposition, anIndexErrorshould be raised.