/[escript]/trunk/escript/test/python/insituTests.py
ViewVC logotype

Annotation of /trunk/escript/test/python/insituTests.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 374 - (hide annotations)
Fri Dec 16 01:35:07 2005 UTC (15 years, 10 months ago) by jgs
File MIME type: text/x-python
File size: 1666 byte(s)
fix names of log/ln functions to match new scheme

1 jgs 153 """
2    
3     Random interactive escript/Data tests.
4    
5     Version $Id$
6    
7     """
8    
9     import os
10     import sys
11     import unittest
12     import math
13    
14     from esys.escript import *
15     from esys import bruce
16    
17     arglist = [ \
18     3.0, \
19     [3,4], \
20     [[1,2],[3,4]], \
21     [[15,8],[12,8]], \
22     [[[15,8],[12,8]],[[-9,9],[13,8]]] \
23     ]
24    
25     #
26     # ==============================================================
27    
28     class escriptTestCase(unittest.TestCase):
29    
30     def setUp(self):
31     self.msh=bruce.Rectangle()
32    
33     def prepareArg(self,val,ex,wh):
34     if ex=="Expanded":
35     exx=True
36     else:
37     exx=False
38     out=Data(val,what=wh,expand=exx)
39     return out
40    
41     def testAlina1(self):
42     P1 = 10.0
43 jgs 374 assert log10(P1) == math.log10(10.0)
44     assert log(P1) == math.log(10.0,math.e)
45 jgs 153
46     def testAlina2(self):
47     P = 10.0*Scalar(1.0, ContinuousFunction(self.msh))
48 jgs 374 assert log10(P).convertToNumArray()[0] == math.log10(10.0)
49     assert log(P).convertToNumArray()[0] == math.log(10.0,math.e)
50 jgs 153
51     def testLog(self):
52     for wh in [ContinuousFunction(self.msh),Function(self.msh)]:
53     for ex in ["Constant","Expanded"]:
54     for a in arglist:
55     #print "\n", ex, a, "==>"
56     arg=self.prepareArg(a,ex,wh)
57     #print "\nlog"
58 jgs 374 result = arg._log10()
59 jgs 153
60     def testLn(self):
61     for wh in [ContinuousFunction(self.msh),Function(self.msh)]:
62     for ex in ["Constant","Expanded"]:
63     for a in arglist:
64     #print "\n", ex, a, "==>"
65     arg=self.prepareArg(a,ex,wh)
66     #print "\nln"
67 jgs 374 result = arg._log()
68 jgs 153
69     if __name__ == '__main__':
70     suite=unittest.TestSuite()
71     suite.addTest(unittest.makeSuite(escriptTestCase))
72     unittest.TextTestRunner(verbosity=2).run(suite)
73    
74     sys.exit(0)
75     # end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26