/[escript]/trunk/esys2/escript/test/python/escriptTest.py
ViewVC logotype

Contents of /trunk/esys2/escript/test/python/escriptTest.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (show annotations)
Tue Oct 26 06:53:54 2004 UTC (14 years, 8 months ago) by jgs
File MIME type: text/x-python
File size: 1930 byte(s)
Initial revision

1 import sys
2 import unittest
3 import os
4
5 esys_root=os.getenv('ESYS_ROOT')
6 sys.path.append(esys_root+'/finley/lib')
7 sys.path.append(esys_root+'/escript/lib')
8 sys.path.append(esys_root+'/escript/py_src')
9
10
11 import escript
12 import finley
13 import numarray
14
15 class escriptTestCase(unittest.TestCase):
16 def testPow(self):
17 """Test the pow function."""
18 myFuncSpac=escript.FunctionSpace()
19 myVector=numarray.array([[1,2],[3,4]])
20 myData=escript.Data(myVector,myFuncSpac,True)
21 print myData**3
22 def testFunctionSpace(self):
23 """Test the creation of FunctionSpace objects."""
24 print
25 mesh=finley.Brick(1,1,1,1,1.,1.,1.,1,1,1,1,1)
26 cFunc=escript.ContinuousFunction(mesh)
27 def testDataOperations(self):
28 """Test the operations that may be performed on Data."""
29 myFuncSpac=escript.FunctionSpace()
30 myVector=numarray.array([[1,2],[3,4]])
31 myData=escript.Data(myVector,myFuncSpac,True)
32 myData2=3+myData
33 print myData2
34 myList=[[1,2],[3,4]]
35 myData3=myList+myData
36 print myData3
37 myData3=myData+myData2+myData3
38 print myData3
39 myData4=myList-myData
40 print myData4
41 myData5=0-myData
42 print myData5
43 myData6=1/myData
44 print myData6
45 myData7=5*myData
46 print myData7
47 myData8=(3*myData)/3+2*myData-2*myData
48 print myData8
49 myData9=myData.sin()
50 print myData9
51 myData9=myData.cos()
52 print myData9
53 print myData9.wherePositive()
54 print myData9.whereNegative()
55 #
56 # Lsup test for DataExpanded
57 assert (myData.Lsup()==4)
58 assert (myData.inf()==1)
59 assert (myData.Lsup()==myData.sup())
60 assert ((myData*-1).sup()!=(myData*-1).Lsup())
61 #
62 # Lsup test for DataConstant
63 myData10=escript.Data(myVector,myFuncSpac,False)
64 myData11=-1.0*myData10
65 assert(myData10.Lsup()==myData11.Lsup())
66
67 suite=unittest.TestSuite()
68 suite.addTest(unittest.makeSuite(escriptTestCase))
69 unittest.TextTestRunner(verbosity=2).run(suite)
70
71
72
73

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26