Skip to content

Commit ac73b1c

Browse files
committed
Add a notes section to the unstack docstring
1 parent 221299d commit ac73b1c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

numpy/_core/shape_base.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,7 @@ def unstack(x, /, *, axis=0):
468468
The ``axis`` parameter specifies the axis along which the array will be
469469
split. of the new axis in the dimensions of the result. For example, if
470470
``axis=0`` it will be the first dimension and if ``axis=-1`` it will be
471-
the last dimension.
472-
473-
The result is a tuple of arrays split along ``axis``. ``unstack`` serves
474-
as the reverse operation of :py:func:`stack`, i.e., ``stack(unstack(x,
475-
axis=axis), axis=axis) == x``.
471+
the last dimension. The result is a tuple of arrays split along ``axis``.
476472
477473
.. versionadded:: 2.1.0
478474
@@ -493,6 +489,14 @@ def unstack(x, /, *, axis=0):
493489
block : Assemble an nd-array from nested lists of blocks.
494490
split : Split array into a list of multiple sub-arrays of equal size.
495491
492+
Notes
493+
-----
494+
``unstack`` serves as the reverse operation of :py:func:`stack`, i.e.,
495+
``stack(unstack(x, axis=axis), axis=axis) == x``.
496+
497+
This function is equivalent to tuple(np.moveaxis(x, axis, 0)), since
498+
iterating on an array iterates along the first axis.
499+
496500
Examples
497501
--------
498502
>>> arr = np.arange(24).reshape((2, 3, 4))

0 commit comments

Comments
 (0)