Skip to content

Commit cb07c38

Browse files
Added tests to cover branches in copy from Numpy array to usm array
1 parent 4580c71 commit cb07c38

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

dpctl/tests/test_tensor_asarray.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,19 @@ def test_asarray_from_numpy():
6767
Xnp = np.arange(10)
6868
Y = dpt.asarray(Xnp, usm_type="device")
6969
assert type(Y) is dpt.usm_ndarray
70-
assert Y.shape == (10,)
70+
assert Y.shape == Xnp.shape
71+
assert Y.dtype == Xnp.dtype
72+
# Fortan contiguous case
73+
Xnp = np.array([[1, 2, 3], [4, 5, 6]], dtype="f4", order="F")
74+
Y = dpt.asarray(Xnp, usm_type="shared")
75+
assert type(Y) is dpt.usm_ndarray
76+
assert Y.shape == Xnp.shape
77+
assert Y.dtype == Xnp.dtype
78+
# general strided case
79+
Xnp = np.array([[1, 2, 3], [4, 5, 6]], dtype="i8")
80+
Y = dpt.asarray(Xnp[::-1, ::-1], usm_type="host")
81+
assert type(Y) is dpt.usm_ndarray
82+
assert Y.shape == Xnp.shape
7183
assert Y.dtype == Xnp.dtype
7284

7385

0 commit comments

Comments
 (0)