1# Tests domain errors in special math functions
2
3try:
4    import math
5
6    math.erf
7except (ImportError, AttributeError):
8    print("SKIP")
9    raise SystemExit
10
11inf = float("inf")
12nan = float("nan")
13
14# single argument functions
15for name, f, args in (
16    ("expm1", math.exp, ()),
17    ("log2", math.log2, (-1, 0)),
18    ("log10", math.log10, (-1, 0)),
19    ("sinh", math.sinh, ()),
20    ("cosh", math.cosh, ()),
21    ("tanh", math.tanh, ()),
22    ("asinh", math.asinh, ()),
23    ("acosh", math.acosh, (-1, 0.9, 1)),
24    ("atanh", math.atanh, (-1, 1)),
25    ("erf", math.erf, ()),
26    ("erfc", math.erfc, ()),
27    ("gamma", math.gamma, (-2, -1, 0, 1)),
28    ("lgamma", math.lgamma, (-2, -1, 0, 1)),
29):
30    for x in args + (inf, -inf, nan):
31        try:
32            ans = f(x)
33            print("%.4f" % ans)
34        except ValueError:
35            print(name, "ValueError")
36        except OverflowError:
37            print(name, "OverflowError")
38