Skip to content

Commit 316254b

Browse files
committed
Test diff with an empty array and axis
1 parent 6ae2ac2 commit 316254b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

dpctl/tests/test_tensor_diff.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,22 @@ def test_diff_0d():
122122
x = dpt.ones(())
123123
with pytest.raises(ValueError):
124124
dpt.diff(x)
125+
126+
127+
def test_diff_empty_array():
128+
get_queue_or_skip()
129+
130+
x = dpt.ones((3, 0, 5))
131+
res = dpt.diff(x, axis=1)
132+
assert res.shape == x.shape
133+
134+
res = dpt.diff(x, axis=0)
135+
assert res.shape == (2, 0, 5)
136+
137+
append = dpt.ones((3, 2, 5))
138+
res = dpt.diff(x, axis=1, append=append)
139+
assert res.shape == (3, 1, 5)
140+
141+
prepend = dpt.ones((3, 2, 5))
142+
res = dpt.diff(x, axis=1, prepend=prepend)
143+
assert res.shape == (3, 1, 5)

0 commit comments

Comments
 (0)