Skip to content

Commit e933da5

Browse files
committed
Added test for empty arrays in any/all
1 parent 4694a25 commit e933da5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

dpctl/tests/test_usm_ndarray_utility_functions.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,24 @@ def test_boolean_reduction_axis(func, identity):
8484

8585

8686
@pytest.mark.parametrize("func", [dpt.all, dpt.any])
87-
def test_all_any_keepdims(func):
87+
def test_boolean_reduction_keepdims(func):
8888
get_queue_or_skip()
8989

9090
x = dpt.ones((2, 3, 4, 5, 6), dtype="i4")
91-
9291
res = func(x, axis=(1, 2, -1), keepdims=True)
9392
assert res.shape == (2, 1, 1, 5, 1)
9493
assert_array_equal(dpt.asnumpy(res), np.full(res.shape, True))
9594

9695

96+
@pytest.mark.parametrize("func,identity", [(dpt.all, True), (dpt.any, False)])
97+
def test_boolean_reduction_empty(func, identity):
98+
get_queue_or_skip()
99+
100+
x = dpt.empty((0,), dtype="i4")
101+
res = func(x)
102+
assert_equal(dpt.asnumpy(res), identity)
103+
104+
97105
# nan, inf, and -inf should evaluate to true
98106
@pytest.mark.parametrize("func", [dpt.all, dpt.any])
99107
def test_boolean_reductions_nan_inf(func):

0 commit comments

Comments
 (0)