-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathtest_acos.py
66 lines (46 loc) · 1.74 KB
/
test_acos.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
"""
Special cases tests for acos.
These tests are generated from the special cases listed in the spec.
NOTE: This file is generated automatically by the generate_stubs.py script. Do
not modify it directly.
"""
from ..array_helpers import NaN, assert_exactly_equal, exactly_equal, greater, less, one, zero
from ..hypothesis_helpers import numeric_arrays
from .._array_module import acos
from hypothesis import given
@given(numeric_arrays)
def test_acos_special_cases_one_arg_equal_1(arg1):
"""
Special case test for `acos(x, /)`:
- If `x_i` is `NaN`, the result is `NaN`.
"""
res = acos(arg1)
mask = exactly_equal(arg1, NaN(arg1.shape, arg1.dtype))
assert_exactly_equal(res[mask], (NaN(arg1.shape, arg1.dtype))[mask])
@given(numeric_arrays)
def test_acos_special_cases_one_arg_equal_2(arg1):
"""
Special case test for `acos(x, /)`:
- If `x_i` is `1`, the result is `+0`.
"""
res = acos(arg1)
mask = exactly_equal(arg1, one(arg1.shape, arg1.dtype))
assert_exactly_equal(res[mask], (zero(arg1.shape, arg1.dtype))[mask])
@given(numeric_arrays)
def test_acos_special_cases_one_arg_greater(arg1):
"""
Special case test for `acos(x, /)`:
- If `x_i` is greater than `1`, the result is `NaN`.
"""
res = acos(arg1)
mask = greater(arg1, one(arg1.shape, arg1.dtype))
assert_exactly_equal(res[mask], (NaN(arg1.shape, arg1.dtype))[mask])
@given(numeric_arrays)
def test_acos_special_cases_one_arg_less(arg1):
"""
Special case test for `acos(x, /)`:
- If `x_i` is less than `-1`, the result is `NaN`.
"""
res = acos(arg1)
mask = less(arg1, -one(arg1.shape, arg1.dtype))
assert_exactly_equal(res[mask], (NaN(arg1.shape, arg1.dtype))[mask])