|
20 | 20 | from .third_party.cupy import testing |
21 | 21 |
|
22 | 22 |
|
23 | | -@pytest.mark.usefixtures("suppress_complex_warning") |
24 | | -@pytest.mark.parametrize("res_dtype", get_all_dtypes()) |
25 | | -@pytest.mark.parametrize("arr_dtype", get_all_dtypes()) |
26 | | -@pytest.mark.parametrize( |
27 | | - "arr", |
28 | | - [[-2, -1, 0, 1, 2], [[-2, -1], [1, 2]], []], |
29 | | - ids=["[-2, -1, 0, 1, 2]", "[[-2, -1], [1, 2]]", "[]"], |
30 | | -) |
31 | | -def test_astype(arr, arr_dtype, res_dtype): |
32 | | - numpy_array = get_abs_array(arr, arr_dtype) |
33 | | - dpnp_array = dpnp.array(numpy_array) |
34 | | - expected = numpy_array.astype(res_dtype) |
35 | | - result = dpnp_array.astype(res_dtype) |
36 | | - assert_allclose(expected, result) |
| 23 | +class TestAsType: |
| 24 | + @pytest.mark.usefixtures("suppress_complex_warning") |
| 25 | + @pytest.mark.parametrize("res_dtype", get_all_dtypes()) |
| 26 | + @pytest.mark.parametrize("arr_dtype", get_all_dtypes()) |
| 27 | + @pytest.mark.parametrize( |
| 28 | + "arr", |
| 29 | + [[-2, -1, 0, 1, 2], [[-2, -1], [1, 2]], []], |
| 30 | + ids=["1d", "2d", "empty"], |
| 31 | + ) |
| 32 | + def test_basic(self, arr, arr_dtype, res_dtype): |
| 33 | + a = get_abs_array(arr, arr_dtype) |
| 34 | + ia = dpnp.array(a) |
37 | 35 |
|
| 36 | + expected = a.astype(res_dtype) |
| 37 | + result = ia.astype(res_dtype) |
| 38 | + assert_allclose(expected, result) |
38 | 39 |
|
39 | | -def test_astype_subok_error(): |
40 | | - x = dpnp.ones((4)) |
41 | | - with pytest.raises(NotImplementedError): |
42 | | - x.astype("i4", subok=False) |
| 40 | + def test_subok_error(self): |
| 41 | + x = dpnp.ones((4)) |
| 42 | + with pytest.raises(NotImplementedError): |
| 43 | + x.astype("i4", subok=False) |
43 | 44 |
|
44 | 45 |
|
45 | 46 | class TestAttributes: |
|
0 commit comments