Skip to content

Commit 221299d

Browse files
committed
Simplify the implementation of unstack()
1 parent a500831 commit 221299d

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

numpy/_core/shape_base.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,7 @@ def unstack(x, /, *, axis=0):
517517
np.True_
518518
519519
"""
520-
x = asanyarray(x)
521-
522-
axis = normalize_axis_index(axis, x.ndim)
523-
slices = (slice(None),) * axis
524-
return tuple(x[slices + (i, ...)] for i in range(x.shape[axis]))
520+
return tuple(_nx.moveaxis(x, axis, 0))
525521

526522
# Internal functions to eliminate the overhead of repeated dispatch in one of
527523
# the two possible paths inside np.block.

0 commit comments

Comments
 (0)