0001 #! /usr/bin/env python 0002 """ Simple test script for cmathmodule.c 0003 Roger E. Masse 0004 """ 0005 import cmath, math 0006 from test.test_support import verbose, verify, TestFailed 0007 0008 verify(abs(cmath.log(10) - math.log(10)) < 1e-9) 0009 verify(abs(cmath.log(10,2) - math.log(10,2)) < 1e-9) 0010 try: 0011 cmath.log('a') 0012 except TypeError: 0013 pass 0014 else: 0015 raise TestFailed 0016 0017 try: 0018 cmath.log(10, 'a') 0019 except TypeError: 0020 pass 0021 else: 0022 raise TestFailed 0023 0024 0025 testdict = {'acos' : 1.0, 0026 'acosh' : 1.0, 0027 'asin' : 1.0, 0028 'asinh' : 1.0, 0029 'atan' : 0.2, 0030 'atanh' : 0.2, 0031 'cos' : 1.0, 0032 'cosh' : 1.0, 0033 'exp' : 1.0, 0034 'log' : 1.0, 0035 'log10' : 1.0, 0036 'sin' : 1.0, 0037 'sinh' : 1.0, 0038 'sqrt' : 1.0, 0039 'tan' : 1.0, 0040 'tanh' : 1.0} 0041 0042 for func in testdict.keys(): 0043 f = getattr(cmath, func) 0044 r = f(testdict[func]) 0045 if verbose: 0046 print 'Calling %s(%f) = %f' % (func, testdict[func], abs(r)) 0047 0048 p = cmath.pi 0049 e = cmath.e 0050 if verbose: 0051 print 'PI = ', abs(p) 0052 print 'E = ', abs(e) 0053
Generated by PyXR 0.9.4