Skip to content

Commit edace9e

Browse files
committed
More tests for compress added
1 parent ec299bc commit edace9e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

dpnp/tests/test_indexing.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,3 +1387,22 @@ def test_compress_empty_axis(self):
13871387
# non-empty take from empty axis raises IndexError
13881388
with pytest.raises(IndexError):
13891389
dpnp.compress(condition, a, axis=1)
1390+
1391+
def test_compress_in_overlaps_out(self):
1392+
conditions = [False, True, True]
1393+
a_np = numpy.arange(6)
1394+
a = dpnp.arange(6)
1395+
cond_np = numpy.array(conditions)
1396+
cond = dpnp.array(conditions)
1397+
out = a[2:4]
1398+
expected = numpy.compress(cond_np, a_np, axis=None)
1399+
result = dpnp.compress(cond, a, axis=None, out=out)
1400+
assert_array_equal(expected, result)
1401+
assert result is out
1402+
assert (a[2:4] == out).all()
1403+
1404+
def test_compress_condition_not_1d(self):
1405+
a = dpnp.arange(4)
1406+
cond = dpnp.ones((1, 4), dtype="?")
1407+
with pytest.raises(ValueError):
1408+
dpnp.compress(cond, a, axis=None)

0 commit comments

Comments
 (0)