Skip to content

Commit 913918b

Browse files
Update test_amin_amax and use black 22.6.0
1 parent 2280773 commit 913918b

File tree

1 file changed

+58
-28
lines changed

1 file changed

+58
-28
lines changed

tests/test_amin_amax.py

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
import numpy
66

77

8-
@pytest.mark.parametrize("type",
9-
[numpy.float64],
10-
ids=['float64'])
11-
def test_amax_float64(type):
12-
a = numpy.array([[[-2., 3.], [9.1, 0.2]], [[-2., 5.0], [-2, -1.2]], [[1.0, -2.], [5.0, -1.1]]])
8+
@pytest.mark.parametrize("type", [numpy.float64], ids=[pytest.floatMAX])
9+
def test_amax_float(type):
10+
a = numpy.array(
11+
[
12+
[[-2.0, 3.0], [9.1, 0.2]],
13+
[[-2.0, 5.0], [-2, -1.2]],
14+
[[1.0, -2.0], [5.0, -1.1]],
15+
],
16+
dtype=pytest.floatMAX,
17+
)
1318
ia = dpnp.array(a)
1419

1520
for axis in range(len(a)):
@@ -18,9 +23,7 @@ def test_amax_float64(type):
1823
numpy.testing.assert_array_equal(expected, result)
1924

2025

21-
@pytest.mark.parametrize("type",
22-
[numpy.int64],
23-
ids=['int64'])
26+
@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"])
2427
def test_amax_int(type):
2528
a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9])
2629
ia = dpnp.array(a)
@@ -30,11 +33,16 @@ def test_amax_int(type):
3033
numpy.testing.assert_array_equal(expected, result)
3134

3235

33-
@pytest.mark.parametrize("type",
34-
[numpy.float64],
35-
ids=['float64'])
36-
def test_amin_float64(type):
37-
a = numpy.array([[[-2., 3.], [9.1, 0.2]], [[-2., 5.0], [-2, -1.2]], [[1.0, -2.], [5.0, -1.1]]])
36+
@pytest.mark.parametrize("type", [numpy.float64], ids=[pytest.floatMAX])
37+
def test_amin_float(type):
38+
a = numpy.array(
39+
[
40+
[[-2.0, 3.0], [9.1, 0.2]],
41+
[[-2.0, 5.0], [-2, -1.2]],
42+
[[1.0, -2.0], [5.0, -1.1]],
43+
],
44+
dtype=pytest.floatMAX,
45+
)
3846
ia = dpnp.array(a)
3947

4048
for axis in range(len(a)):
@@ -43,9 +51,7 @@ def test_amin_float64(type):
4351
numpy.testing.assert_array_equal(expected, result)
4452

4553

46-
@pytest.mark.parametrize("type",
47-
[numpy.int64],
48-
ids=['int64'])
54+
@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"])
4955
def test_amin_int(type):
5056
a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9])
5157
ia = dpnp.array(a)
@@ -68,12 +74,24 @@ def _get_min_max_input(type, shape):
6874

6975

7076
@pytest.mark.usefixtures("allow_fall_back_on_numpy")
71-
@pytest.mark.parametrize("type",
72-
[numpy.float64, numpy.float32, numpy.int64, numpy.int32],
73-
ids=['float64', 'float32', 'int64', 'int32'])
74-
@pytest.mark.parametrize("shape",
75-
[(4,), (2, 3), (4, 5, 6)],
76-
ids=['(4,)', '(2,3)', '(4,5,6)'])
77+
@pytest.mark.parametrize(
78+
"type",
79+
[
80+
pytest.param(
81+
numpy.float64,
82+
marks=pytest.mark.skipif(
83+
pytest.floatMAX != "float64", reason="No float64 support on this device"
84+
),
85+
),
86+
numpy.float32,
87+
numpy.int64,
88+
numpy.int32,
89+
],
90+
ids=["float64", "float32", "int64", "int32"],
91+
)
92+
@pytest.mark.parametrize(
93+
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"]
94+
)
7795
def test_amax(type, shape):
7896
a = _get_min_max_input(type, shape)
7997

@@ -89,12 +107,24 @@ def test_amax(type, shape):
89107

90108

91109
@pytest.mark.usefixtures("allow_fall_back_on_numpy")
92-
@pytest.mark.parametrize("type",
93-
[numpy.float64, numpy.float32, numpy.int64, numpy.int32],
94-
ids=['float64', 'float32', 'int64', 'int32'])
95-
@pytest.mark.parametrize("shape",
96-
[(4,), (2, 3), (4, 5, 6)],
97-
ids=['(4,)', '(2,3)', '(4,5,6)'])
110+
@pytest.mark.parametrize(
111+
"type",
112+
[
113+
pytest.param(
114+
numpy.float64,
115+
marks=pytest.mark.skipif(
116+
pytest.floatMAX != "float64", reason="No float64 support on this device"
117+
),
118+
),
119+
numpy.float32,
120+
numpy.int64,
121+
numpy.int32,
122+
],
123+
ids=["float64", "float32", "int64", "int32"],
124+
)
125+
@pytest.mark.parametrize(
126+
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"]
127+
)
98128
def test_amin(type, shape):
99129
a = _get_min_max_input(type, shape)
100130

0 commit comments

Comments
 (0)