Skip to content

Commit 457de03

Browse files
committed
Raise for 0-d input
1 parent d2cc53f commit 457de03

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

numpy/_core/shape_base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,8 @@ def unstack(x, /, *, axis=0):
524524
np.True_
525525
526526
"""
527+
if x.ndim == 0:
528+
raise ValueError("Input array must be at least 1-d.")
527529
return tuple(_nx.moveaxis(x, axis, 0))
528530

529531
# Internal functions to eliminate the overhead of repeated dispatch in one of

numpy/_core/tests/test_shape_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ def test_unstack():
520520

521521
assert_raises(ValueError, np.unstack, a, axis=3)
522522
assert_raises(ValueError, np.unstack, a, axis=-4)
523+
assert_raises(ValueError, np.unstack, np.array(0), axis=0)
523524

524525

525526
@pytest.mark.parametrize("axis", [0])

0 commit comments

Comments
 (0)