|
13 | 13 | assert_dtype_allclose,
|
14 | 14 | generate_random_numpy_array,
|
15 | 15 | get_all_dtypes,
|
| 16 | + get_unsigned_dtypes, |
16 | 17 | )
|
17 | 18 |
|
18 | 19 |
|
@@ -77,10 +78,24 @@ def custom_func(x, axis):
|
77 | 78 |
|
78 | 79 |
|
79 | 80 | 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 | + ) |
81 | 84 | @pytest.mark.parametrize("funclist", [[True, False], [-1, 1], [-1.5, 1.5]])
|
82 | 85 | 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) |
84 | 99 | ia = dpnp.array(a)
|
85 | 100 |
|
86 | 101 | expected = numpy.piecewise(a, [a < 0, a >= 0], funclist)
|
|
0 commit comments