cmath_fun_special.py 827 B

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