77not modify it directly.
88"""
99
10- from ..array_helpers import (assert_exactly_equal , assert_iseven , assert_positive , ceil , equal ,
11- floor , isintegral , logical_and , not_equal , one , subtract )
10+ from ..array_helpers import (NaN , assert_exactly_equal , assert_iseven , assert_positive , ceil , equal ,
11+ exactly_equal , floor , infinity , isintegral , logical_and , not_equal ,
12+ one , subtract , zero )
1213from ..hypothesis_helpers import numeric_arrays
1314from .._array_module import round
1415
1516from hypothesis import given
1617
1718
1819@given (numeric_arrays )
19- def test_round_special_cases_one_arg_equal (arg1 ):
20+ def test_round_special_cases_one_arg_equal_1 (arg1 ):
2021 """
2122 Special case test for `round(x, /)`:
2223
@@ -28,6 +29,71 @@ def test_round_special_cases_one_arg_equal(arg1):
2829 assert_exactly_equal (res [mask ], (arg1 )[mask ])
2930
3031
32+ @given (numeric_arrays )
33+ def test_round_special_cases_one_arg_equal_2 (arg1 ):
34+ """
35+ Special case test for `round(x, /)`:
36+
37+ - If `x_i` is `+infinity`, the result is `+infinity`.
38+
39+ """
40+ res = round (arg1 )
41+ mask = exactly_equal (arg1 , infinity (arg1 .shape , arg1 .dtype ))
42+ assert_exactly_equal (res [mask ], (infinity (arg1 .shape , arg1 .dtype ))[mask ])
43+
44+
45+ @given (numeric_arrays )
46+ def test_round_special_cases_one_arg_equal_3 (arg1 ):
47+ """
48+ Special case test for `round(x, /)`:
49+
50+ - If `x_i` is `-infinity`, the result is `-infinity`.
51+
52+ """
53+ res = round (arg1 )
54+ mask = exactly_equal (arg1 , - infinity (arg1 .shape , arg1 .dtype ))
55+ assert_exactly_equal (res [mask ], (- infinity (arg1 .shape , arg1 .dtype ))[mask ])
56+
57+
58+ @given (numeric_arrays )
59+ def test_round_special_cases_one_arg_equal_4 (arg1 ):
60+ """
61+ Special case test for `round(x, /)`:
62+
63+ - If `x_i` is `+0`, the result is `+0`.
64+
65+ """
66+ res = round (arg1 )
67+ mask = exactly_equal (arg1 , zero (arg1 .shape , arg1 .dtype ))
68+ assert_exactly_equal (res [mask ], (zero (arg1 .shape , arg1 .dtype ))[mask ])
69+
70+
71+ @given (numeric_arrays )
72+ def test_round_special_cases_one_arg_equal_5 (arg1 ):
73+ """
74+ Special case test for `round(x, /)`:
75+
76+ - If `x_i` is `-0`, the result is `-0`.
77+
78+ """
79+ res = round (arg1 )
80+ mask = exactly_equal (arg1 , - zero (arg1 .shape , arg1 .dtype ))
81+ assert_exactly_equal (res [mask ], (- zero (arg1 .shape , arg1 .dtype ))[mask ])
82+
83+
84+ @given (numeric_arrays )
85+ def test_round_special_cases_one_arg_equal_6 (arg1 ):
86+ """
87+ Special case test for `round(x, /)`:
88+
89+ - If `x_i` is `NaN`, the result is `NaN`.
90+
91+ """
92+ res = round (arg1 )
93+ mask = exactly_equal (arg1 , NaN (arg1 .shape , arg1 .dtype ))
94+ assert_exactly_equal (res [mask ], (NaN (arg1 .shape , arg1 .dtype ))[mask ])
95+
96+
3197@given (numeric_arrays )
3298def test_round_special_cases_one_arg_two_integers_equally_close (arg1 ):
3399 """
0 commit comments