Skip to content

Commit 9921320

Browse files
committed
Update tests for aastype method
1 parent 7fff293 commit 9921320

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

dpnp/tests/test_ndarray.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,27 @@
2020
from .third_party.cupy import testing
2121

2222

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)
3735

36+
expected = a.astype(res_dtype)
37+
result = ia.astype(res_dtype)
38+
assert_allclose(expected, result)
3839

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)
4344

4445

4546
class TestAttributes:

0 commit comments

Comments
 (0)