/[escript]/branches/domexper/finley/test/python/run_escriptOnFinley.py
ViewVC logotype

Diff of /branches/domexper/finley/test/python/run_escriptOnFinley.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2344 by jfenwick, Mon Mar 30 02:13:58 2009 UTC revision 2628 by jfenwick, Tue Aug 25 03:50:00 2009 UTC
# Line 1  Line 1 
1    
2  ########################################################  ########################################################
3  #  #
4  # Copyright (c) 2003-2008 by University of Queensland  # Copyright (c) 2003-2009 by University of Queensland
5  # Earth Systems Science Computational Center (ESSCC)  # Earth Systems Science Computational Center (ESSCC)
6  # http://www.uq.edu.au/esscc  # http://www.uq.edu.au/esscc
7  #  #
# Line 11  Line 11 
11  #  #
12  ########################################################  ########################################################
13    
14  __copyright__="""Copyright (c) 2003-2008 by University of Queensland  __copyright__="""Copyright (c) 2003-2009 by University of Queensland
15  Earth Systems Science Computational Center (ESSCC)  Earth Systems Science Computational Center (ESSCC)
16  http://www.uq.edu.au/esscc  http://www.uq.edu.au/esscc
17  Primary Business: Queensland, Australia"""  Primary Business: Queensland, Australia"""
# Line 48  class Test_SharedOnFinley(Test_Shared): Line 48  class Test_SharedOnFinley(Test_Shared):
48    
49  class Test_DomainOnFinley(Test_Domain):  class Test_DomainOnFinley(Test_Domain):
50     def setUp(self):     def setUp(self):
51           self.boundary_tag_list = [1, 2, 10, 20]
52         self.domain =Rectangle(NE,NE+1,2)         self.domain =Rectangle(NE,NE+1,2)
53     def tearDown(self):     def tearDown(self):
54         del self.domain         del self.domain
55           del self.boundary_tag_list
56    
57     def test_tagsContinuousFunction(self):     def test_tagsContinuousFunction(self):
58         ref_tags=[0]         ref_tags=[0]
# Line 115  class Test_DataOpsOnFinley(Test_Dump, Te Line 117  class Test_DataOpsOnFinley(Test_Dump, Te
117         del self.domain_with_different_number_of_data_points_per_sample         del self.domain_with_different_number_of_data_points_per_sample
118         del self.domain_with_different_sample_ordering         del self.domain_with_different_sample_ordering
119    
120    #Some of this functionality could be tested in escript but we need
121    #the rectangle domain for the rest of it
122    class Test_TableInterpolation(unittest.TestCase):
123        
124        RES_TOL=1.e-7 # RES_TOLerance to compare results    
125        
126    
127        def test_NullFunctionSpace(self):
128        arL=[[0, -1, -2, -3, -4], [1, 1, -2, -3, -4], [2, 2, 2, -3, -4], [3, 3, 3, 3, -4], [4, 4, 4, 4, 4]]
129        arn=numpy.array(arL)
130        ars=[arL,arn]
131        d0=Data(0)
132        d1=Data(1)
133        d2=Data(2)
134        d35=Data(3.5)
135        d4=Data(4)
136        dm05=Data(-0.5)
137        d175=Data(1.75)
138        d225=Data(2.25)
139        for arr in ars:
140            self.failUnless(Lsup(d1.interpolateTable(arL,0, 1, 100, d2, 0, 1)+2)<self.RES_TOL)
141            self.failUnless(Lsup(d1.interpolateTable(arL,0, 1, 100, d35, 0, 1)+3.5)<self.RES_TOL)
142            self.failUnless(Lsup(d35.interpolateTable(arL,0,1, 100, d2, 0, 1)-3.5)<self.RES_TOL)
143            self.failUnless(Lsup(d175.interpolateTable(arL,0,1,100,d225,0,1)-0)<self.RES_TOL)
144            self.failUnless(Lsup(d2.interpolateTable(arL, 1, 4, 100, d2, -1, 4)-0.25)<self.RES_TOL)
145               # Point out of bounds
146            self.failUnlessRaises(RuntimeError, d1.interpolateTable,arL,0, 1, 100, d4, 0, 1 )
147            self.failUnlessRaises(RuntimeError, d4.interpolateTable, arL,0, 1, 100, d1, 0, 1 )
148            self.failUnlessRaises(RuntimeError, dm05.interpolateTable, arL,0,1, 100, d1 , 0,1 )
149            self.failUnlessRaises(RuntimeError, d1.interpolateTable, arL,0,1, 100, dm05 , 0,1 )
150               # interpolated value too large
151            self.failUnlessRaises(RuntimeError, d2.interpolateTable, arL, 0, 1, 1, d2, 0, 1 )
152    
153        def test_Rectangle(self):
154        bounds=2
155        r=Rectangle(n0=bounds, n1=bounds, l0=bounds, l1=bounds)
156        x=r.getX()
157        arr=[]
158        for j in xrange(bounds+2):
159           v=[]
160           for k in xrange(bounds+2):
161                v.append(k)
162           arr.append(v)
163        arr=numpy.array(arr)
164        x0=x[0]
165        x1=x[1]
166        d100=Data(100)
167        self.failUnlessRaises(RuntimeError, d100.interpolateTable, arr, 0, 1, 5, d100,0,1)
168        zz=x0.interpolateTable(arr,0,1,100,x1,0,1)
169        
170            
171  if __name__ == '__main__':  if __name__ == '__main__':
172     suite = unittest.TestSuite()     suite = unittest.TestSuite()
173     suite.addTest(unittest.makeSuite(Test_SharedOnFinley))     suite.addTest(unittest.makeSuite(Test_SharedOnFinley))
174     suite.addTest(unittest.makeSuite(Test_DataOpsOnFinley))     suite.addTest(unittest.makeSuite(Test_DataOpsOnFinley))
175     suite.addTest(unittest.makeSuite(Test_DomainOnFinley))     suite.addTest(unittest.makeSuite(Test_DomainOnFinley))
176       suite.addTest(unittest.makeSuite(Test_TableInterpolation))
177     s=unittest.TextTestRunner(verbosity=2).run(suite)     s=unittest.TextTestRunner(verbosity=2).run(suite)
178     if not s.wasSuccessful(): sys.exit(1)     if not s.wasSuccessful(): sys.exit(1)
179    

Legend:
Removed from v.2344  
changed lines
  Added in v.2628

  ViewVC Help
Powered by ViewVC 1.1.26