|
6 | 6 | p_test_values = [0.1, 0.5, 1.23456] |
7 | 7 | unit_range_test_values = [-1., -0.75, -0.5, -0.25, 0., 0.25, 0.5, 0.75, 1.] |
8 | 8 |
|
9 | | -functions = [(sqrt, p_test_values), |
10 | | - (exp, test_values), |
11 | | - (expm1, test_values), |
12 | | - (log, p_test_values), |
13 | | - (log2, p_test_values), |
14 | | - (log10, p_test_values), |
15 | | - (cosh, test_values), |
16 | | - (sinh, test_values), |
17 | | - (tanh, test_values), |
18 | | - (acosh, [1.0, 5.0, 1.0]), |
19 | | - (asinh, test_values), |
20 | | - (atanh, [-0.99, -0.5, 0.0, 0.5, 0.99]), |
21 | | - (cos, test_values), |
22 | | - (sin, test_values), |
23 | | - (tan, test_values), |
24 | | - (acos, unit_range_test_values), |
25 | | - (asin, unit_range_test_values), |
26 | | - (atan, test_values), |
27 | | - (ceil, test_values), |
28 | | - (fabs, test_values), |
29 | | - (floor, test_values), |
30 | | - #(frexp, test_values), |
31 | | - (trunc, test_values) |
| 9 | +functions = [('sqrt', sqrt, p_test_values), |
| 10 | + ('exp', exp, test_values), |
| 11 | + ('expm1', expm1, test_values), |
| 12 | + ('log', log, p_test_values), |
| 13 | + ('log2', log2, p_test_values), |
| 14 | + ('log10', log10, p_test_values), |
| 15 | + ('cosh', cosh, test_values), |
| 16 | + ('sinh', sinh, test_values), |
| 17 | + ('tanh', tanh, test_values), |
| 18 | + ('acosh', acosh, [1.0, 5.0, 1.0]), |
| 19 | + ('asinh', asinh, test_values), |
| 20 | + ('atanh', atanh, [-0.99, -0.5, 0.0, 0.5, 0.99]), |
| 21 | + ('cos', cos, test_values), |
| 22 | + ('sin', sin, test_values), |
| 23 | + ('tan', tan, test_values), |
| 24 | + ('acos', acos, unit_range_test_values), |
| 25 | + ('asin', asin, unit_range_test_values), |
| 26 | + ('atan', atan, test_values), |
| 27 | + ('ceil', ceil, test_values), |
| 28 | + ('fabs', fabs, test_values), |
| 29 | + ('floor', floor, test_values), |
| 30 | + #('frexp', frexp, test_values), |
| 31 | + ('trunc', trunc, test_values) |
32 | 32 | ] |
33 | 33 |
|
34 | | -for function, test_vals in functions: |
| 34 | +for function_name, function, test_vals in functions: |
| 35 | + print(function_name) |
35 | 36 | for value in test_vals: |
36 | | - print("{:8.7f}".format(function(value))) |
| 37 | + print("{:8.7g}".format(function(value))) |
37 | 38 |
|
38 | | -binary_functions = [(copysign, [(23., 42.), (-23., 42.), (23., -42.), |
| 39 | +binary_functions = [('copysign', copysign, [(23., 42.), (-23., 42.), (23., -42.), |
39 | 40 | (-23., -42.), (1., 0.0), (1., -0.0)]) |
40 | 41 | ] |
41 | 42 |
|
42 | | -for function, test_vals in binary_functions: |
| 43 | +for function_name, function, test_vals in binary_functions: |
| 44 | + print(function_name) |
43 | 45 | for value1, value2 in test_vals: |
44 | | - print("{:8.7f}".format(function(value1, value2))) |
45 | | - |
46 | | - |
| 46 | + print("{:8.7g}".format(function(value1, value2))) |
0 commit comments