Skip to content

Commit 86153f3

Browse files
committed
Adds tests for unaligned clip, where, copy
1 parent a307c00 commit 86153f3

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

dpctl/tests/test_tensor_clip.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,3 +625,14 @@ def test_clip_max_weak_types():
625625

626626
with pytest.raises(ValueError):
627627
dpt.clip(x, 2.5, m)
628+
629+
630+
def test_clip_unaligned():
631+
get_queue_or_skip()
632+
633+
x = dpt.full(513, 5, dtype="i4")
634+
a_min = dpt.zeros(512, dtype="i4")
635+
a_max = dpt.full(512, 2, dtype="i4")
636+
637+
expected = dpt.full(512, 2, dtype="i4")
638+
assert dpt.all(dpt.clip(x[1:], a_min, a_max) == expected)

dpctl/tests/test_usm_ndarray_ctor.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,15 @@ def test_copy():
13261326
assert np.array_equal(dpt.asnumpy(Yk), ref)
13271327

13281328

1329+
def test_copy_unaligned():
1330+
get_queue_or_skip()
1331+
1332+
x = dpt.ones(513, dtype="i4")
1333+
r = dpt.astype(x[1:], "f4")
1334+
1335+
assert dpt.all(r == 1)
1336+
1337+
13291338
def test_ctor_invalid():
13301339
try:
13311340
m = dpm.MemoryUSMShared(12)

dpctl/tests/test_usm_ndarray_search_functions.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,14 @@ def test_where_order():
412412
condition = dpt.zeros(n, dtype="?", order="C")
413413
res = dpt.where(condition, ar1, ar2)
414414
assert res.strides == (20, 1)
415+
416+
417+
def test_where_unaligned():
418+
get_queue_or_skip()
419+
420+
x = dpt.ones(513, dtype="i4")
421+
a = dpt.full(512, 2, dtype="i4")
422+
b = dpt.zeros(512, dtype="i4")
423+
424+
expected = dpt.full(512, 2, dtype="i4")
425+
assert dpt.all(dpt.where(x[1:], a, b) == expected)

0 commit comments

Comments
 (0)