Skip to content

Commit 83de252

Browse files
author
Vahid Tavanashad
committed
update newly added tests
1 parent d1b7777 commit 83de252

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

dpnp/tests/test_indexing.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def test_input_1d(self, a_dt, indices, ind_dt, ivals, mode):
473473
b.put(ind, vals, mode=mode)
474474
ib.put(iind, ivals, mode=mode)
475475
assert_array_equal(ib, b)
476-
elif numpy.issubdtype(ind_dt, numpy.uint64):
476+
elif ind_dt == numpy.uint64:
477477
# For this special case, NumPy raises an error but dpnp works
478478
assert_raises(TypeError, numpy.put, a, ind, vals, mode=mode)
479479
assert_raises(TypeError, b.put, ind, vals, mode=mode)
@@ -508,7 +508,7 @@ def test_input_2d(self, a_dt, indices, ind_dt, mode):
508508
ind = get_abs_array(indices, ind_dt)
509509
iind = dpnp.array(ind)
510510

511-
if numpy.issubdtype(ind_dt, numpy.uint64):
511+
if ind_dt == numpy.uint64:
512512
# For this special case, NumPy raises an error but dpnp works
513513
assert_raises(TypeError, numpy.put, a, ind, vals, mode=mode)
514514

@@ -656,7 +656,7 @@ def test_broadcast(self, arr_dt, idx_dt):
656656
ind = numpy.arange(10, dtype=idx_dt).reshape((1, 2, 5)) % 4
657657
ia, iind = dpnp.array(a), dpnp.array(ind)
658658

659-
if numpy.issubdtype(idx_dt, numpy.uint64):
659+
if idx_dt == numpy.uint64:
660660
numpy.put_along_axis(a, ind, 20, axis=1)
661661
dpnp.put_along_axis(ia, iind, 20, axis=1)
662662
assert_array_equal(ia, a)
@@ -701,7 +701,7 @@ def test_1d(self, a_dt, ind_dt, indices, mode):
701701
result = dpnp.take(ia, iind, mode=mode)
702702
expected = numpy.take(a, ind, mode=mode)
703703
assert_array_equal(result, expected)
704-
elif numpy.issubdtype(ind_dt, numpy.uint64):
704+
elif ind_dt == numpy.uint64:
705705
# For this special case, although casting `ind_dt` to numpy.intp
706706
# is not safe, both NumPy and dpnp work properly
707707
# NumPy < "2.2.0" raises an error
@@ -726,7 +726,7 @@ def test_2d(self, a_dt, ind_dt, indices, mode, axis):
726726
ind = get_abs_array(indices, ind_dt)
727727
ia, iind = dpnp.array(a), dpnp.array(ind)
728728

729-
if numpy.issubdtype(ind_dt, numpy.uint64):
729+
if ind_dt == numpy.uint64:
730730
# For this special case, NumPy raises an error on Windows
731731
result = ia.take(iind, axis=axis, mode=mode)
732732
expected = a.take(ind.astype(numpy.int64), axis=axis, mode=mode)
@@ -1461,6 +1461,16 @@ def test_choose_inds_all_dtypes(self, dtype):
14611461
chcs = dpnp.ones(1, dtype=dtype)
14621462
with pytest.raises(TypeError):
14631463
dpnp.choose(inds, chcs)
1464+
elif dtype == numpy.uint64:
1465+
# For this special case, NumPy raises an error but dpnp works
1466+
inds_np = numpy.array([1, 0, 1], dtype=dtype)
1467+
inds = dpnp.array(inds_np)
1468+
chcs_np = numpy.array([1, 2, 3], dtype=dtype)
1469+
chcs = dpnp.array(chcs_np)
1470+
assert_raises(TypeError, numpy.choose, inds_np, chcs_np)
1471+
expected = numpy.choose(inds_np.astype(numpy.int64), chcs_np)
1472+
result = dpnp.choose(inds, chcs)
1473+
assert_array_equal(expected, result)
14641474
else:
14651475
inds_np = numpy.array([1, 0, 1], dtype=dtype)
14661476
inds = dpnp.array(inds_np)

dpnp/tests/test_product.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1449,8 +1449,8 @@ def setup_method(self):
14491449
],
14501450
)
14511451
def test_basic(self, dtype, shape1, shape2):
1452-
a = generate_random_numpy_array(shape1, dtype)
1453-
b = generate_random_numpy_array(shape2, dtype)
1452+
a = generate_random_numpy_array(shape1, dtype, low=-5, high=5)
1453+
b = generate_random_numpy_array(shape2, dtype, low=-5, high=5)
14541454
ia, ib = dpnp.array(a), dpnp.array(b)
14551455

14561456
result = dpnp.matvec(ia, ib)
@@ -2171,8 +2171,8 @@ def setup_method(self):
21712171
],
21722172
)
21732173
def test_basic(self, dtype, shape1, shape2):
2174-
a = generate_random_numpy_array(shape1, dtype)
2175-
b = generate_random_numpy_array(shape2, dtype)
2174+
a = generate_random_numpy_array(shape1, dtype, low=-5, high=5)
2175+
b = generate_random_numpy_array(shape2, dtype, low=-5, high=5)
21762176
ia, ib = dpnp.array(a), dpnp.array(b)
21772177

21782178
result = dpnp.vecmat(ia, ib)

dpnp/tests/test_statistics.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,12 @@ def test_correlate(self, a, v, mode, dtype, method):
219219
@pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True))
220220
@pytest.mark.parametrize("method", ["auto", "direct", "fft"])
221221
def test_correlate_random(self, a_size, v_size, mode, dtype, method):
222-
an = generate_random_numpy_array(a_size, dtype, probability=0.9)
223-
vn = generate_random_numpy_array(v_size, dtype, probability=0.9)
222+
an = generate_random_numpy_array(
223+
a_size, dtype, low=-3, high=3, probability=0.9
224+
)
225+
vn = generate_random_numpy_array(
226+
v_size, dtype, low=-3, high=3, probability=0.9
227+
)
224228

225229
ad = dpnp.array(an)
226230
vd = dpnp.array(vn)

0 commit comments

Comments
 (0)