Content-Security-Policy: default-src 'none'
Content-Type: text/plain; charset=UTF-8
Content-Length: 1104
Content-Disposition: inline; filename="test_cmath.py"
Last-Modified: Tue, 18 Nov 2025 02:05:32 GMT
Expires: Fri, 16 Nov 2035 02:05:32 GMT
ETag: "6e392928c3c989b355a79509900f2548c0755a09"
#! /usr/bin/env python
""" Simple test script for cmathmodule.c
Roger E. Masse
"""
import cmath, math
from test.test_support import verbose, verify, TestFailed
verify(abs(cmath.log(10) - math.log(10)) < 1e-9)
verify(abs(cmath.log(10,2) - math.log(10,2)) < 1e-9)
try:
cmath.log('a')
except TypeError:
pass
else:
raise TestFailed
try:
cmath.log(10, 'a')
except TypeError:
pass
else:
raise TestFailed
testdict = {'acos' : 1.0,
'acosh' : 1.0,
'asin' : 1.0,
'asinh' : 1.0,
'atan' : 0.2,
'atanh' : 0.2,
'cos' : 1.0,
'cosh' : 1.0,
'exp' : 1.0,
'log' : 1.0,
'log10' : 1.0,
'sin' : 1.0,
'sinh' : 1.0,
'sqrt' : 1.0,
'tan' : 1.0,
'tanh' : 1.0}
for func in testdict.keys():
f = getattr(cmath, func)
r = f(testdict[func])
if verbose:
print 'Calling %s(%f) = %f' % (func, testdict[func], abs(r))
p = cmath.pi
e = cmath.e
if verbose:
print 'PI = ', abs(p)
print 'E = ', abs(e)
g'>benjamin-clang
| https://github.com/python/cpython.git | |
blob: e83ca09fb7ad691e23394ebabd907649c5b7a21c (
plain)
1
2
3
4
5
6
|
import os
if __name__ == '__main__':
buf = os.read(0, 1024)
os.write(1, b'OUT:'+buf)
os.write(2, b'ERR:'+buf)
|