Skip to content

Commit 2b18781

Browse files
committed
Minor fix in tests for full() and full_like() functions
1 parent de3e5ad commit 2b18781

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

dpnp/dpnp_iface_arraycreation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ def full_like(x1,
729729
730730
Limitations
731731
-----------
732+
Parameters ``x1`` is supported only as :class:`dpnp.dpnp_array`.
732733
Parameter ``order`` is supported only with values ``"C"`` and ``"F"``.
733734
Parameter ``subok`` is supported only with default value ``False``.
734735
Otherwise the function will be executed sequentially on CPU.

tests/test_arraycreation.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,6 @@ def test_full_like(array, fill_value, dtype):
382382

383383
expected = numpy.full_like(a, fill_value, dtype=dtype)
384384
result = dpnp.full_like(ia, fill_value, dtype=dtype)
385-
386-
assert expected.shape == result.shape
387-
assert expected.dtype == result.dtype
388385
numpy.testing.assert_array_equal(expected, result)
389386

390387

@@ -409,16 +406,15 @@ def test_full_strides():
409406
a = numpy.full((3, 3), numpy.arange(3, dtype="i4"))
410407
ia = dpnp.full((3, 3), dpnp.arange(3, dtype="i4"))
411408
assert ia.strides == tuple(el // a.itemsize for el in a.strides)
412-
assert numpy.array_equal(dpnp.asnumpy(ia), a)
409+
numpy.testing.assert_array_equal(dpnp.asnumpy(ia), a)
413410

414411
a = numpy.full((3, 3), numpy.arange(6, dtype="i4")[::2])
415412
ia = dpnp.full((3, 3), dpnp.arange(6, dtype="i4")[::2])
416413
assert ia.strides == tuple(el // a.itemsize for el in a.strides)
417-
assert numpy.array_equal(dpnp.asnumpy(ia), a)
414+
numpy.testing.assert_array_equal(dpnp.asnumpy(ia), a)
418415

419416

420-
def test_full_invalid_fill_value():
421-
with pytest.raises(ValueError):
422-
dpnp.full(10, [])
417+
@pytest.mark.parametrize("fill_value", [[], (), dpnp.full(0, 0)], ids=['[]', '()', 'dpnp.full(0, 0)'])
418+
def test_full_invalid_fill_value(fill_value):
423419
with pytest.raises(ValueError):
424-
dpnp.full(10, dpnp.full(0, 0))
420+
dpnp.full(10, fill_value=fill_value)

tests/test_sycl_queue.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ def test_array_creation_like(func, kwargs, device_x, device_y):
116116

117117
y = getattr(dpnp, func)(x, **kwargs)
118118
numpy.testing.assert_array_equal(y_orig, y)
119-
assert y.sycl_device == device_x
119+
assert_sycl_queue_equal(y.sycl_queue, x.sycl_queue)
120120

121121
dpnp_kwargs = dict(kwargs)
122122
dpnp_kwargs['device'] = device_y
123123

124124
y = getattr(dpnp, func)(x, **dpnp_kwargs)
125125
numpy.testing.assert_array_equal(y_orig, y)
126-
assert y.sycl_device == device_y
126+
assert_sycl_queue_equal(y.sycl_queue, x.to_device(device_y).sycl_queue)
127127

128128

129129
@pytest.mark.usefixtures("allow_fall_back_on_numpy")

tests/test_usm_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ def test_array_creation(usm_type_x, usm_type_y):
4949
x = dp.full_like(x0, 4)
5050
y = dp.full_like(x0, 4, usm_type=usm_type_y)
5151
assert x.usm_type == usm_type_x
52-
assert y.usm_type == usm_type_y
52+
assert y.usm_type == usm_type_y

0 commit comments

Comments
 (0)