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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 698 - (show annotations)
Fri Mar 31 04:52:55 2006 UTC (15 years, 4 months ago) by gross
File MIME type: text/x-python
File size: 3946 byte(s)
test with tagged data pass now
1 # $Id:$
2 """
3 frame to ran a single test out of the Test_util suite
4 """
5
6 __copyright__=""" Copyright (c) 2006 by ACcESS MNRF
7 http://www.access.edu.au
8 Primary Business: Queensland, Australia"""
9 __license__="""Licensed under the Open Software License version 3.0
10 http://www.opensource.org/licenses/osl-3.0.php"""
11 import unittest
12 from esys.escript import *
13 from esys.finley import Rectangle
14 import numarray
15
16 class Test_util2(unittest.TestCase):
17 RES_TOL=1.e-7
18 def setUp(self):
19 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
21 def test_add_overloaded_constData_rank1_taggedData_rank0(self):
22 arg0=Data(numarray.array([4.5897569702707663, 3.4489828945022865]),self.functionspace)
23 arg1=Data(0.812494849561,self.functionspace)
24 arg1.setTaggedValue(1,-0.798066999908)
25 res=arg0+arg1
26 ref=Data(numarray.array([5.4022518198315126, 4.2614777440630327]),self.functionspace)
27 ref.setTaggedValue(1,numarray.array([3.7916899703627909, 2.650915894594311]))
28 print arg0
29 print arg1
30 print res
31 print ref
32 self.failUnless(isinstance(res,Data),"wrong type of result.")
33 self.failUnlessEqual(res.getShape(),(2,),"wrong shape of result.")
34 self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
35
36 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
37 def test_mult_overloaded_constData_rank1_taggedData_rank0(self):
38 arg0=Data(numarray.array([-1.8021292916234133, 0.52610779274754549]),self.functionspace)
39 arg1=Data(-2.10992701792,self.functionspace)
40 arg1.setTaggedValue(1,-0.103414543531)
41 res=arg0*arg1
42 ref=Data(numarray.array([3.8023612821737358, -1.1100490462541024]),self.functionspace)
43 ref.setTaggedValue(1,numarray.array([0.18636637807672213, -0.054407197234984987]))
44 self.failUnless(isinstance(res,Data),"wrong type of result.")
45 self.failUnlessEqual(res.getShape(),(2,),"wrong shape of result.")
46 self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
47
48 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
49 def test_pow_overloaded_taggedData_rank1_taggedData_rank0(self):
50 arg0=Data(numarray.array([2.3271463200997102, 1.1183883755594386]),self.functionspace)
51 arg0.setTaggedValue(1,numarray.array([3.8629630953883574, 3.7380725394052305]))
52 arg1=Data(4.96280973024,self.functionspace)
53 arg1.setTaggedValue(1,1.353354768)
54 res=arg0**arg1
55 ref=Data(numarray.array([66.141826047243441, 1.7424328429281473]),self.functionspace)
56 ref.setTaggedValue(1,numarray.array([6.2274713351642141, 5.9565601105055705]))
57 self.failUnless(isinstance(res,Data),"wrong type of result.")
58 self.failUnlessEqual(res.getShape(),(2,),"wrong shape of result.")
59 self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
60 #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
61 def test_quotient_overloaded_constData_rank1_taggedData_rank0(self):
62 arg0=Data(numarray.array([3.2585370968848757, 1.1454175877624291]),self.functionspace)
63 arg1=Data(-2.93544378089,self.functionspace)
64 arg1.setTaggedValue(1,-1.7765826732)
65 res=arg0/arg1
66 ref=Data(numarray.array([-1.1100662591795942, -0.39020252924586424]),self.functionspace)
67 ref.setTaggedValue(1,numarray.array([-1.8341601244001815, -0.64473081103446983]))
68 self.failUnless(isinstance(res,Data),"wrong type of result.")
69 self.failUnlessEqual(res.getShape(),(2,),"wrong shape of result.")
70 self.failUnless(Lsup(res-ref)<=self.RES_TOL*Lsup(ref),"wrong result")
71
72 if __name__ == '__main__':
73 suite = unittest.TestSuite()
74 suite.addTest(unittest.makeSuite(Test_util2))
75 s=unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26