Skip to content

Commit be68602

Browse files
committed
fix dtype for unsigned integer test
1 parent 807e731 commit be68602

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

dpnp/tests/test_functional.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
assert_dtype_allclose,
1414
generate_random_numpy_array,
1515
get_all_dtypes,
16+
get_unsigned_dtypes,
1617
)
1718

1819

@@ -77,10 +78,24 @@ def custom_func(x, axis):
7778

7879

7980
class TestPiecewise:
80-
@pytest.mark.parametrize("dtype", get_all_dtypes(no_none=True))
81+
@pytest.mark.parametrize(
82+
"dtype", get_all_dtypes(no_none=True, no_unsigned=True)
83+
)
8184
@pytest.mark.parametrize("funclist", [[True, False], [-1, 1], [-1.5, 1.5]])
8285
def test_basic(self, dtype, funclist):
83-
a = generate_random_numpy_array(10, dtype=dtype)
86+
low = 0 if dpnp.issubdtype(dtype, dpnp.unsignedinteger) else -10
87+
a = generate_random_numpy_array(10, dtype=dtype, low=low)
88+
ia = dpnp.array(a)
89+
90+
expected = numpy.piecewise(a, [a < 0, a >= 0], funclist)
91+
result = dpnp.piecewise(ia, [ia < 0, ia >= 0], funclist)
92+
assert a.dtype == result.dtype
93+
assert_dtype_allclose(result, expected)
94+
95+
@pytest.mark.parametrize("dtype", get_unsigned_dtypes())
96+
@pytest.mark.parametrize("funclist", [[True, False], [1, 2], [1.5, 4.5]])
97+
def test_unsigned(self, dtype, funclist):
98+
a = generate_random_numpy_array(10, dtype=dtype, low=0)
8499
ia = dpnp.array(a)
85100

86101
expected = numpy.piecewise(a, [a < 0, a >= 0], funclist)

0 commit comments

Comments
 (0)