Skip to content

Commit 1b7d987

Browse files
committed
Add test_2d_axis_unsigned_inetger to keep the same coverage lever
1 parent 234c8af commit 1b7d987

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

dpnp/tests/helper.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def get_integer_dtypes(all_int_types=False, no_unsigned=False):
343343
if config.all_int_types or all_int_types:
344344
dtypes += [dpnp.int8, dpnp.int16]
345345
if not no_unsigned:
346-
dtypes += [dpnp.uint8, dpnp.uint16, dpnp.uint32, dpnp.uint64]
346+
dtypes += get_unsigned_dtypes()
347347

348348
return dtypes
349349

@@ -378,6 +378,14 @@ def not_excluded(dtype):
378378
return dtypes
379379

380380

381+
def get_unsigned_dtypes():
382+
"""
383+
Build a list of unsigned integer types supported by DPNP.
384+
"""
385+
386+
return [dpnp.uint8, dpnp.uint16, dpnp.uint32, dpnp.uint64]
387+
388+
381389
def has_support_aspect16(device=None):
382390
"""
383391
Return True if the device supports 16-bit precision floating point operations,

dpnp/tests/test_manipulation.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
get_float_dtypes,
2222
get_integer_dtypes,
2323
get_integer_float_dtypes,
24+
get_unsigned_dtypes,
2425
has_support_aspect64,
2526
numpy_version,
2627
)
@@ -1799,8 +1800,18 @@ def test_2d_axis_signed_inetger(self, dt):
17991800
expected = numpy.unique(a, axis=0)
18001801
assert_array_equal(result, expected)
18011802

1803+
@pytest.mark.parametrize("axis", [None, 0, 1])
1804+
@pytest.mark.parametrize("dt", get_unsigned_dtypes())
1805+
def test_2d_axis_unsigned_inetger(self, axis, dt):
1806+
a = numpy.array([[7, 1, 2, 1], [5, 7, 5, 7]], dtype=dt)
1807+
ia = dpnp.array(a)
1808+
1809+
result = dpnp.unique(ia, axis=axis)
1810+
expected = numpy.unique(a, axis=axis)
1811+
assert_array_equal(result, expected)
1812+
18021813
@pytest.mark.parametrize("axis", [None, 0])
1803-
@pytest.mark.parametrize("dt", "bBhHiIlLqQ")
1814+
@pytest.mark.parametrize("dt", get_integer_dtypes(all_int_types=True))
18041815
def test_1d_axis_all_inetger(self, axis, dt):
18051816
a = numpy.array([5, 7, 1, 2, 1, 5, 7], dtype=dt)
18061817
ia = dpnp.array(a)

0 commit comments

Comments
 (0)