1# test the special functions imported from math
2
3try:
4    from math import *
5
6    erf
7except (ImportError, NameError):
8    print("SKIP")
9    raise SystemExit
10
11test_values = [
12    -8.0,
13    -2.5,
14    -1,
15    -0.5,
16    0.0,
17    0.5,
18    2.5,
19    8.0,
20]
21pos_test_values = [
22    0.001,
23    0.1,
24    0.5,
25    1.0,
26    1.5,
27    10.0,
28]
29
30functions = [
31    ("expm1", expm1, test_values),
32    ("log2", log2, test_values),
33    ("log10", log10, test_values),
34    ("cosh", cosh, test_values),
35    ("sinh", sinh, test_values),
36    ("tanh", tanh, [-1e6, -100] + test_values + [100, 1e6]),
37    ("acosh", acosh, [1.0, 5.0, 1.0]),
38    ("asinh", asinh, test_values),
39    ("atanh", atanh, [-0.99, -0.5, 0.0, 0.5, 0.99]),
40    ("erf", erf, test_values),
41    ("erfc", erfc, test_values),
42    ("gamma", gamma, pos_test_values),
43    ("lgamma", lgamma, pos_test_values + [50.0, 100.0]),
44]
45
46for function_name, function, test_vals in functions:
47    print(function_name)
48    for value in test_vals:
49        try:
50            print("{:.4g}".format(function(value)))
51        except ValueError as e:
52            print(str(e))
53