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