tests: Allow float tests to run when MATH_SPECIAL_FUNCTIONS is disabled. · csamuelson/circuitpython@b1fa907 · GitHub
Skip to content

Commit b1fa907

Browse files
committed
tests: Allow float tests to run when MATH_SPECIAL_FUNCTIONS is disabled.
1 parent 978d2e5 commit b1fa907

4 files changed

Lines changed: 45 additions & 11 deletions

File tree

tests/float/cmath_fun.py

Lines changed: 0 additions & 1 deletion

tests/float/cmath_fun_special.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# test the special functions imported from cmath
2+
3+
try:
4+
from cmath import *
5+
log10
6+
except (ImportError, NameError):
7+
print("SKIP")
8+
import sys
9+
sys.exit()
10+
11+
test_values_non_zero = []
12+
base_values = (0.0, 0.5, 1.2345, 10.)
13+
for r in base_values:
14+
for i in base_values:
15+
if r != 0. or i != 0.:
16+
test_values_non_zero.append(complex(r, i))
17+
if r != 0.:
18+
test_values_non_zero.append(complex(-r, i))
19+
if i != 0.:
20+
test_values_non_zero.append(complex(r, -i))
21+
if r != 0. and i != 0.:
22+
test_values_non_zero.append(complex(-r, -i))
23+
24+
functions = [
25+
('log10', log10, test_values_non_zero),
26+
]
27+
28+
for f_name, f, test_vals in functions:
29+
print(f_name)
30+
for val in test_vals:
31+
ret = f(val)
32+
print("complex(%.5g, %.5g)" % (ret.real, ret.imag))

tests/float/math_fun.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,7 @@
1313

1414
functions = [('sqrt', sqrt, test_values),
1515
('exp', exp, test_values_small),
16-
('expm1', expm1, test_values_small),
1716
('log', log, test_values),
18-
('log2', log2, test_values),
19-
('log10', log10, test_values),
20-
('cosh', cosh, test_values_small),
21-
('sinh', sinh, test_values_small),
22-
('tanh', tanh, test_values_small),
23-
('acosh', acosh, [1.0, 5.0, 1.0]),
24-
('asinh', asinh, test_values),
25-
('atanh', atanh, [-0.99, -0.5, 0.0, 0.5, 0.99]),
2617
('cos', cos, test_values),
2718
('sin', sin, test_values),
2819
('tan', tan, test_values),

tests/float/math_fun_special.py

Lines changed: 13 additions & 1 deletion

0 commit comments

Comments
 (0)