Skip to content

Commit 5d6b9d1

Browse files
committed
TST: Test basic nd-support for trim_zeros
1 parent 9fd1bbf commit 5d6b9d1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

numpy/lib/tests/test_function_base.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,13 @@ def test_trailing_skip(self):
11331133
res = trim_zeros(a)
11341134
assert_array_equal(res, np.array([1, 0, 2, 3, 0, 4]))
11351135

1136+
@pytest.mark.parametrize("ndim", (0, 1, 2, 3, 10))
1137+
def test_nd_basic(self, ndim):
1138+
a = np.ones((2,) * ndim)
1139+
b = np.pad(a, (2, 1), mode="constant", constant_values=0)
1140+
res = trim_zeros(b, axis=None)
1141+
assert_array_equal(a, res)
1142+
11361143

11371144
class TestExtins(object):
11381145

0 commit comments

Comments
 (0)