/[escript]/trunk/finley/test/python/test_utilframe.py
ViewVC logotype

Diff of /trunk/finley/test/python/test_utilframe.py

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

revision 619 by gross, Wed Mar 22 04:02:38 2006 UTC revision 620 by gross, Wed Mar 22 07:43:42 2006 UTC
# Line 18  class Test_util2(unittest.TestCase): Line 18  class Test_util2(unittest.TestCase):
18     def setUp(self):     def setUp(self):
19         self.__dom =Rectangle(10,10,2)         self.__dom =Rectangle(10,10,2)
20         self.functionspace = FunctionOnBoundary(self.__dom) # due to a bug in escript python needs to hold a reference to the domain         self.functionspace = FunctionOnBoundary(self.__dom) # due to a bug in escript python needs to hold a reference to the domain
21     def itest_add_overloaded_constData_rank1_taggedData_rank0(self):     def test_add_overloaded_constData_rank1_taggedData_rank0(self):
22         arg0=Data(numarray.array([4.5897569702707663, 3.4489828945022865]),self.functionspace)         arg0=Data(numarray.array([4.5897569702707663, 3.4489828945022865]),self.functionspace)
23         arg1=Data(0.812494849561,self.functionspace)         arg1=Data(0.812494849561,self.functionspace)
24         arg1.setTaggedValue(1,-0.798066999908)         arg1.setTaggedValue(1,-0.798066999908)
        print arg0  
        print arg1  
25         res=arg0+arg1         res=arg0+arg1
        print res  
26         ref=Data(numarray.array([5.4022518198315126, 4.2614777440630327]),self.functionspace)         ref=Data(numarray.array([5.4022518198315126, 4.2614777440630327]),self.functionspace)
27         ref.setTaggedValue(1,numarray.array([3.7916899703627909, 2.650915894594311]))         ref.setTaggedValue(1,numarray.array([3.7916899703627909, 2.650915894594311]))
28         self.failUnless(isinstance(res,Data),"wrong type of result.")         self.failUnless(isinstance(res,Data),"wrong type of result.")
29         self.failUnlessEqual(res.getShape(),(2,),"wrong shape of result.")         self.failUnlessEqual(res.getShape(),(2,),"wrong shape of result.")
30         self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")         self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
31        #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  
32     def test_inverse_array_dim1(self):     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33        arg=numarray.array([[1.3914367298126584]])     def test_mult_overloaded_constData_rank1_taggedData_rank0(self):
34        res=inverse(arg)        arg0=Data(numarray.array([-1.8021292916234133, 0.52610779274754549]),self.functionspace)
35        self.failUnless(isinstance(res,numarray.NumArray),"wrong type of result.")        arg1=Data(-2.10992701792,self.functionspace)
36        self.failUnlessEqual(res.shape,(1, 1),"wrong shape of result.")        arg1.setTaggedValue(1,-0.103414543531)
37        self.failUnless(Lsup(matrixmult(res,arg)-kronecker(1))<=self.RES_TOL,"wrong result")        res=arg0*arg1
38          ref=Data(numarray.array([3.8023612821737358, -1.1100490462541024]),self.functionspace)
39          ref.setTaggedValue(1,numarray.array([0.18636637807672213, -0.054407197234984987]))
40          self.failUnless(isinstance(res,Data),"wrong type of result.")
41          self.failUnlessEqual(res.getShape(),(2,),"wrong shape of result.")
42          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
43    
44       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45       def test_pow_overloaded_taggedData_rank1_taggedData_rank0(self):
46          arg0=Data(numarray.array([2.3271463200997102, 1.1183883755594386]),self.functionspace)
47          arg0.setTaggedValue(1,numarray.array([3.8629630953883574, 3.7380725394052305]))
48          arg1=Data(4.96280973024,self.functionspace)
49          arg1.setTaggedValue(1,1.353354768)
50          res=arg0**arg1
51          ref=Data(numarray.array([66.141826047243441, 1.7424328429281473]),self.functionspace)
52          ref.setTaggedValue(1,numarray.array([6.2274713351642141, 5.9565601105055705]))
53          self.failUnless(isinstance(res,Data),"wrong type of result.")
54          self.failUnlessEqual(res.getShape(),(2,),"wrong shape of result.")
55          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
56       #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    
57       def test_quotient_overloaded_constData_rank1_taggedData_rank0(self):
58          arg0=Data(numarray.array([3.2585370968848757, 1.1454175877624291]),self.functionspace)
59          arg1=Data(-2.93544378089,self.functionspace)
60          arg1.setTaggedValue(1,-1.7765826732)
61          res=arg0/arg1
62          ref=Data(numarray.array([-1.1100662591795942, -0.39020252924586424]),self.functionspace)
63          ref.setTaggedValue(1,numarray.array([-1.8341601244001815, -0.64473081103446983]))
64          self.failUnless(isinstance(res,Data),"wrong type of result.")
65          self.failUnlessEqual(res.getShape(),(2,),"wrong shape of result.")
66          self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
67    
68  if __name__ == '__main__':  if __name__ == '__main__':
69     suite = unittest.TestSuite()     suite = unittest.TestSuite()

Legend:
Removed from v.619  
changed lines
  Added in v.620

  ViewVC Help
Powered by ViewVC 1.1.26