Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
np.intp -> "i8" in indexing tests
  • Loading branch information
ndgrigorian committed Mar 17, 2025
commit 1b38641e4ddebeaa8c0592d19fa519a6dc38b612
30 changes: 15 additions & 15 deletions dpctl/tests/test_usm_ndarray_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ def test_put_0d_val(data_dt):
skip_if_dtype_not_supported(data_dt, q)

x = dpt.arange(5, dtype=data_dt, sycl_queue=q)
ind = dpt.asarray([0], dtype=np.intp, sycl_queue=q)
ind = dpt.asarray([0], dtype="i8", sycl_queue=q)
val = dpt.asarray(2, dtype=x.dtype, sycl_queue=q)
x[ind] = val
assert_array_equal(np.asarray(2, dtype=data_dt), dpt.asnumpy(x[0]))
Expand All @@ -644,7 +644,7 @@ def test_take_0d_data(data_dt):
skip_if_dtype_not_supported(data_dt, q)

x = dpt.asarray(0, dtype=data_dt, sycl_queue=q)
ind = dpt.arange(5, dtype=np.intp, sycl_queue=q)
ind = dpt.arange(5, dtype="i8", sycl_queue=q)

y = dpt.take(x, ind)
assert (
Expand All @@ -662,7 +662,7 @@ def test_put_0d_data(data_dt):
skip_if_dtype_not_supported(data_dt, q)

x = dpt.asarray(0, dtype=data_dt, sycl_queue=q)
ind = dpt.arange(5, dtype=np.intp, sycl_queue=q)
ind = dpt.arange(5, dtype="i8", sycl_queue=q)
val = dpt.asarray(2, dtype=data_dt, sycl_queue=q)

dpt.put(x, ind, val, axis=0)
Expand Down Expand Up @@ -710,7 +710,7 @@ def test_take_strided_1d_source(data_dt):
skip_if_dtype_not_supported(data_dt, q)

x = dpt.arange(27, dtype=data_dt, sycl_queue=q)
ind = dpt.arange(4, 9, dtype=np.intp, sycl_queue=q)
ind = dpt.arange(4, 9, dtype="i8", sycl_queue=q)

x_np = dpt.asnumpy(x)
ind_np = dpt.asnumpy(ind)
Expand Down Expand Up @@ -748,7 +748,7 @@ def test_take_strided(data_dt, order):
skip_if_dtype_not_supported(data_dt, q)

x = dpt.reshape(_make_3d(data_dt, q), (9, 3), order=order)
ind = dpt.arange(2, dtype=np.intp, sycl_queue=q)
ind = dpt.arange(2, dtype="i8", sycl_queue=q)

x_np = dpt.asnumpy(x)
ind_np = dpt.asnumpy(ind)
Expand Down Expand Up @@ -781,7 +781,7 @@ def test_take_strided_1d_indices(ind_dt):
ind = dpt.arange(12, 24, dtype=ind_dt, sycl_queue=q)

x_np = dpt.asnumpy(x)
ind_np = dpt.asnumpy(ind).astype(np.intp)
ind_np = dpt.asnumpy(ind).astype("i8")

for s in (
slice(None, None, 2),
Expand Down Expand Up @@ -820,7 +820,7 @@ def test_take_strided_indices(ind_dt, order):
)

x_np = dpt.asnumpy(x)
ind_np = dpt.asnumpy(ind).astype(np.intp)
ind_np = dpt.asnumpy(ind).astype("i8")

for s in (
slice(None, None, 2),
Expand All @@ -845,7 +845,7 @@ def test_put_strided_1d_destination(data_dt, order):
skip_if_dtype_not_supported(data_dt, q)

x = dpt.arange(27, dtype=data_dt, sycl_queue=q)
ind = dpt.arange(4, 9, dtype=np.intp, sycl_queue=q)
ind = dpt.arange(4, 9, dtype="i8", sycl_queue=q)
val = dpt.asarray(9, dtype=x.dtype, sycl_queue=q)

x_np = dpt.asnumpy(x)
Expand Down Expand Up @@ -875,7 +875,7 @@ def test_put_strided_destination(data_dt, order):
skip_if_dtype_not_supported(data_dt, q)

x = dpt.reshape(_make_3d(data_dt, q), (9, 3), order=order)
ind = dpt.arange(2, dtype=np.intp, sycl_queue=q)
ind = dpt.arange(2, dtype="i8", sycl_queue=q)
val = dpt.asarray(9, dtype=x.dtype, sycl_queue=q)

x_np = dpt.asnumpy(x)
Expand Down Expand Up @@ -924,7 +924,7 @@ def test_put_strided_1d_indices(ind_dt):
val = dpt.asarray(-1, dtype=x.dtype, sycl_queue=q)

x_np = dpt.asnumpy(x)
ind_np = dpt.asnumpy(ind).astype(np.intp)
ind_np = dpt.asnumpy(ind).astype("i8")
val_np = dpt.asnumpy(val)

for s in (
Expand Down Expand Up @@ -955,7 +955,7 @@ def test_put_strided_indices(ind_dt, order):
val = dpt.asarray(-1, sycl_queue=q, dtype=x.dtype)

x_np = dpt.asnumpy(x)
ind_np = dpt.asnumpy(ind).astype(np.intp)
ind_np = dpt.asnumpy(ind).astype("i8")
val_np = dpt.asnumpy(val)

for s in (
Expand All @@ -982,15 +982,15 @@ def test_integer_indexing_modes():
x_np = dpt.asnumpy(x)

# wrapping negative indices
ind = dpt.asarray([-4, -3, 0, 2, 4], dtype=np.intp, sycl_queue=q)
ind = dpt.asarray([-4, -3, 0, 2, 4], dtype="i8", sycl_queue=q)

res = dpt.take(x, ind, mode="wrap")
expected_arr = np.take(x_np, dpt.asnumpy(ind), mode="raise")

assert (dpt.asnumpy(res) == expected_arr).all()

# clipping to 0 (disabling negative indices)
ind = dpt.asarray([-6, -3, 0, 2, 6], dtype=np.intp, sycl_queue=q)
ind = dpt.asarray([-6, -3, 0, 2, 6], dtype="i8", sycl_queue=q)

res = dpt.take(x, ind, mode="clip")
expected_arr = np.take(x_np, dpt.asnumpy(ind), mode="clip")
Expand All @@ -1002,7 +1002,7 @@ def test_take_arg_validation():
q = get_queue_or_skip()

x = dpt.arange(4, dtype="i4", sycl_queue=q)
ind0 = dpt.arange(4, dtype=np.intp, sycl_queue=q)
ind0 = dpt.arange(4, dtype="i8", sycl_queue=q)
ind1 = dpt.arange(2.0, dtype="f", sycl_queue=q)

with pytest.raises(TypeError):
Expand Down Expand Up @@ -1034,7 +1034,7 @@ def test_put_arg_validation():
q = get_queue_or_skip()

x = dpt.arange(4, dtype="i4", sycl_queue=q)
ind0 = dpt.arange(4, dtype=np.intp, sycl_queue=q)
ind0 = dpt.arange(4, dtype="i8", sycl_queue=q)
ind1 = dpt.arange(2.0, dtype="f", sycl_queue=q)
val = dpt.asarray(2, dtype=x.dtype, sycl_queue=q)

Expand Down