You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expands the shape of an array by inserting a new axis of size one at the position specified by ``axis``.
84
+
Expands the shape of an array by inserting a new axis of size one at the position (or positions) specified by ``axis``.
85
85
86
86
Parameters
87
87
----------
88
88
x: array
89
89
input array.
90
-
axis: int
91
-
axis position (zero-based). A valid ``axis`` **must** reside on the closed-interval ``[-N-1, N]``, where ``N`` is the number of axes in ``x``. If an axis is specified as a negative integer, the axis position at which to insert a singleton dimension **must** be computed as ``N + axis + 1``. Hence, if provided ``-1``, the resolved axis position **must** be ``N`` (i.e., a singleton dimension **must** be appended to the input array ``x``). If provided ``-N-1``, the resolved axis position **must** be ``0`` (i.e., a singleton dimension **must** be prepended to the input array ``x``). If provided an invalid axis, the function **must** raise an exception.
90
+
axis: Union[int, Tuple[int, ...]]
91
+
axis position(s) (zero-based). A valid axis position **must** reside on the closed-interval ``[-N-1, N]``, where ``N`` is the number of dimensions in ``x``. If an axis position is specified as a negative integer, the axis position at which to insert a singleton dimension **must** be computed as ``N + axis + 1``. Hence, if provided ``-1``, the resolved axis position **must** be ``N`` (i.e., a singleton dimension **must** be appended to the input array ``x``). If provided ``-N-1``, the resolved axis position **must** be ``0`` (i.e., a singleton dimension **must** be prepended to the input array ``x``). If provided an invalid axis position, the function **must** raise an exception.
92
+
93
+
If ``axis`` is a tuple,
94
+
95
+
- each entry of ``axis`` must resolve to a unique axis position. If an entry is a negative integer, the entry **must** resolve to a positive axis position according to the rules described above.
96
+
- if provided an invalid axis position, the function **must** raise an exception.
97
+
- for each entry of ``axis``, the corresponding dimension in the expanded output array **must** be a singleton dimension.
98
+
- for the remaining dimensions of the expanded output array, the output array dimensions **must** correspond to the dimensions of ``x`` in order.
92
99
93
100
Returns
94
101
-------
95
102
out: array
96
-
an expanded output array. **Must** have the same data type as ``x``.
103
+
an expanded output array. **Must** have the same data type as ``x``. If ``axis`` is an integer, the output array must have ``N + 1`` dimensions. If ``axis`` is a tuple, the output array must have ``N + len(axis)`` dimensions.
0 commit comments