annotate Lib/test/test_cmath.py @ 5817:48b94de85bf3 legacy-trunk

Extensive changes by AMK.
author Guido van Rossum <guido@python.org>
date Thu, 17 Jul 1997 16:29:42 +0000
parents db230fefa702
children aedd2d0dcb31
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4638
5f7d246bbeb7 New test module for complex math module
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
1 #! /usr/bin/env python
5f7d246bbeb7 New test module for complex math module
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
2 """ Simple test script for cmathmodule.c
4812
db230fefa702 Very very small comment change.
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4811
diff changeset
3 Roger E. Masse
4638
5f7d246bbeb7 New test module for complex math module
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
4 """
5f7d246bbeb7 New test module for complex math module
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
5 import cmath
4811
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
6 from test_support import verbose
4638
5f7d246bbeb7 New test module for complex math module
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
diff changeset
7
4811
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
8 testdict = {'acos' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
9 'acosh' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
10 'asin' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
11 'asinh' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
12 'atan' : 0.2,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
13 'atanh' : 0.2,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
14 'cos' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
15 'cosh' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
16 'exp' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
17 'log' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
18 'log10' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
19 'sin' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
20 'sinh' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
21 'sqrt' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
22 'tan' : 1.0,
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
23 'tanh' : 1.0}
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
24
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
25 for func in testdict.keys():
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
26 f = getattr(cmath, func)
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
27 r = f(testdict[func])
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
28 if verbose:
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
29 print 'Calling %s(%f) = %f' % (func, testdict[func], abs(r))
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
30
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
31 p = cmath.pi
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
32 e = cmath.e
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
33 if verbose:
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
34 print 'PI = ', abs(p)
9ae3cccfa7cd Many scripts, but small changes. Update the way the scripts obtain the
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents: 4638
diff changeset
35 print 'E = ', abs(e)