Skip to content

Commit 5ba2f41

Browse files
committed
Update indexing tests
1 parent 52b8052 commit 5ba2f41

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

dpnp/tests/test_indexing.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
import dpnp
1818
from dpnp.dpnp_array import dpnp_array
1919

20-
from .helper import get_all_dtypes, get_integer_dtypes, has_support_aspect64
20+
from .helper import (
21+
get_all_dtypes,
22+
get_array,
23+
get_integer_dtypes,
24+
has_support_aspect64,
25+
)
2126
from .third_party.cupy import testing
2227

2328

@@ -441,16 +446,15 @@ class TestPut:
441446
)
442447
@pytest.mark.parametrize("ind_dt", get_all_dtypes(no_none=True))
443448
@pytest.mark.parametrize(
444-
"vals",
449+
"ivals",
445450
[0, [1, 2], (2, 2), dpnp.array([1, 2])],
446451
ids=["0", "[1, 2]", "(2, 2)", "dpnp.array([1,2])"],
447452
)
448453
@pytest.mark.parametrize("mode", ["clip", "wrap"])
449-
def test_input_1d(self, a_dt, indices, ind_dt, vals, mode):
454+
def test_input_1d(self, a_dt, indices, ind_dt, ivals, mode):
450455
a = numpy.array([-2, -1, 0, 1, 2], dtype=a_dt)
451-
b = numpy.copy(a)
452-
ia = dpnp.array(a)
453-
ib = dpnp.array(b)
456+
b, vals = numpy.copy(a), get_array(numpy, ivals)
457+
ia, ib = dpnp.array(a), dpnp.array(b)
454458

455459
ind = numpy.array(indices, dtype=ind_dt)
456460
if ind_dt == dpnp.bool and ind.all():
@@ -459,18 +463,18 @@ def test_input_1d(self, a_dt, indices, ind_dt, vals, mode):
459463

460464
if numpy.can_cast(ind_dt, numpy.intp, casting="safe"):
461465
numpy.put(a, ind, vals, mode=mode)
462-
dpnp.put(ia, iind, vals, mode=mode)
466+
dpnp.put(ia, iind, ivals, mode=mode)
463467
assert_array_equal(ia, a)
464468

465469
b.put(ind, vals, mode=mode)
466-
ib.put(iind, vals, mode=mode)
470+
ib.put(iind, ivals, mode=mode)
467471
assert_array_equal(ib, b)
468472
else:
469473
assert_raises(TypeError, numpy.put, a, ind, vals, mode=mode)
470-
assert_raises(TypeError, dpnp.put, ia, iind, vals, mode=mode)
474+
assert_raises(TypeError, dpnp.put, ia, iind, ivals, mode=mode)
471475

472476
assert_raises(TypeError, b.put, ind, vals, mode=mode)
473-
assert_raises(TypeError, ib.put, iind, vals, mode=mode)
477+
assert_raises(TypeError, ib.put, iind, ivals, mode=mode)
474478

475479
@pytest.mark.parametrize("a_dt", get_all_dtypes(no_none=True))
476480
@pytest.mark.parametrize(
@@ -637,7 +641,7 @@ def test_values(self, arr_dt, idx_dt, ndim, values):
637641
ia, iind = dpnp.array(a), dpnp.array(ind)
638642

639643
for axis in range(ndim):
640-
numpy.put_along_axis(a, ind, values, axis)
644+
numpy.put_along_axis(a, ind, get_array(numpy, values), axis)
641645
dpnp.put_along_axis(ia, iind, values, axis)
642646
assert_array_equal(ia, a)
643647

0 commit comments

Comments
 (0)