/[escript]/trunk/dudley/test/python/run_escriptOnDudley.py
ViewVC logotype

Annotation of /trunk/dudley/test/python/run_escriptOnDudley.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4984 - (hide annotations)
Mon Jun 2 02:50:34 2014 UTC (5 years, 3 months ago) by sshaw
File MIME type: text/x-python
File size: 7294 byte(s)
revamping testrunners, now uses automated discovery and allows running specific tests without modifying files (see escriptcore/py_src/testing.py for more info/examples)

1 ksteube 1809
2 jfenwick 3981 ##############################################################################
3 ksteube 1312 #
4 jfenwick 4657 # Copyright (c) 2003-2014 by University of Queensland
5 jfenwick 3981 # http://www.uq.edu.au
6 ksteube 1312 #
7 ksteube 1809 # Primary Business: Queensland, Australia
8     # Licensed under the Open Software License version 3.0
9     # http://www.opensource.org/licenses/osl-3.0.php
10 ksteube 1312 #
11 jfenwick 3981 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 # Development 2012-2013 by School of Earth Sciences
13     # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 #
15     ##############################################################################
16 gross 983
17 jfenwick 4657 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 jfenwick 3981 http://www.uq.edu.au
19 ksteube 1809 Primary Business: Queensland, Australia"""
20 gross 983 __license__="""Licensed under the Open Software License version 3.0
21 ksteube 1809 http://www.opensource.org/licenses/osl-3.0.php"""
22 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
23 ksteube 1809
24 caltinay 3993 import os
25     import sys
26 jfenwick 4938 import esys.escriptcore.utestselect as unittest
27 sshaw 4984 from esys.escriptcore.testing import *
28 gross 983 from esys.escript import *
29 jfenwick 3368 from esys.dudley import Rectangle, Brick
30 caltinay 3993 from test_objects import Test_Dump, Test_SetDataPointValue, Test_saveCSV, \
31     Test_TableInterpolation, Test_Domain, Test_GlobalMinMax, Test_Lazy
32 jfenwick 2271 from test_shared import Test_Shared
33    
34 gross 983 try:
35 jfenwick 3087 DUDLEY_WORKDIR=os.environ['DUDLEY_WORKDIR']
36 gross 983 except KeyError:
37 jfenwick 3087 DUDLEY_WORKDIR='.'
38 gross 983
39     NE=4 # number elements, must be even
40 jfenwick 2271
41 jfenwick 3087 class Test_SharedOnDudley(Test_Shared):
42 jfenwick 2271 def setUp(self):
43 jfenwick 3892 self.domain=Rectangle(NE,NE)
44     self.tol=0.001
45 jfenwick 2271 def tearDown(self):
46 jfenwick 3892 del self.domain
47     del self.tol
48 jfenwick 2271
49 sshaw 4984 @unittest.skip("Test not previously tested")
50 jfenwick 3087 class Test_DomainOnDudley(Test_Domain):
51 gross 1044 def setUp(self):
52 gross 2425 self.boundary_tag_list = [1, 2, 10, 20]
53 gross 1044 self.domain =Rectangle(NE,NE+1,2)
54 jfenwick 4687 self.rdomain=self.domain
55 caltinay 3993
56 gross 1044 def tearDown(self):
57     del self.domain
58 jfenwick 4687 del self.rdomain
59 caltinay 3993 del self.boundary_tag_list
60    
61 jfenwick 3914 def test_setXError(self):
62     domain=Rectangle(NE,NE)
63 caltinay 3993 x=domain.getX()
64 jfenwick 3914 z=interpolate(x, Function(domain))
65     self.assertRaises(RuntimeError, domain.setX, z)
66     del x
67     del z
68 caltinay 3993 del domain
69 gross 1716
70     def test_tagsContinuousFunction(self):
71     ref_tags=[0]
72     tags=ContinuousFunction(self.domain).getListOfTags()
73 jfenwick 3551 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
74     for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
75 gross 1716
76     def test_tagsFunction(self):
77     ref_tags=[0]
78     tags=Function(self.domain).getListOfTags()
79 jfenwick 3551 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
80     for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
81 sshaw 4984
82 gross 1716 def test_tagsReducedFunction(self):
83     ref_tags=[0]
84     tags=ReducedFunction(self.domain).getListOfTags()
85 jfenwick 3551 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
86     for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
87 sshaw 4984
88 gross 1716 def test_tagsFunctionOnBoundary(self):
89 ksteube 1829 ref_tags=[1, 2, 10, 20]
90     tags=FunctionOnBoundary(self.domain).getListOfTags()
91     # For an MPI-distributed domain some tags may be missing
92 jfenwick 3551 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
93     for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
94 sshaw 4984
95 gross 1716 def test_tagsReducedFunctionOnBoundary(self):
96 ksteube 1829 ref_tags=[1, 2, 10, 20]
97     tags=ReducedFunctionOnBoundary(self.domain).getListOfTags()
98     # For an MPI-distributed domain some tags may be missing
99 jfenwick 3551 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
100     for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
101 gross 1716
102 sshaw 4984 @unittest.skip("Test not previously tested")
103 jfenwick 3087 class Test_DataOpsOnDudley(Test_Dump, Test_SetDataPointValue, Test_GlobalMinMax, Test_Lazy):
104 gross 983 def setUp(self):
105     self.domain =Rectangle(NE,NE+1,2)
106     self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2)
107     self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2)
108 gross 1856 self.domain_with_different_sample_ordering =Rectangle(NE,NE+1,2, optimize=True)
109 jfenwick 3087 self.filename_base=DUDLEY_WORKDIR
110 jfenwick 2799 self.mainfs=Function(self.domain)
111     self.otherfs=Solution(self.domain)
112 gross 983
113     def tearDown(self):
114     del self.domain
115     del self.domain_with_different_number_of_samples
116     del self.domain_with_different_number_of_data_points_per_sample
117     del self.domain_with_different_sample_ordering
118 jfenwick 2799 del self.mainfs
119     del self.otherfs
120 gross 983
121 jfenwick 2628
122 jfenwick 3087 class Test_TableInterpolationOnDudley(Test_TableInterpolation):
123 jfenwick 2646 def setUp(self):
124 jfenwick 3892 self.domain=Brick(4,4,4)
125     self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
126     FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain)]
127     #We aren't testing DiracDeltaFunctions
128     self.xn=5 # number of grids on x axis
129     self.yn=5 # number of grids on y axis
130     self.zn=5
131 jfenwick 2628
132 jfenwick 2646 def tearDown(self):
133 jfenwick 3892 del self.domain
134     del self.functionspaces
135 jfenwick 2646
136 caltinay 3993
137 jfenwick 3087 class Test_CSVOnDudley(Test_saveCSV):
138 caltinay 3993 def setUp(self):
139     NE0=NE
140     NE1=NE+1
141     self.domain=Rectangle(NE0,NE1)
142     self.functionspaces=[ContinuousFunction, ReducedContinuousFunction]
143     # number of total data points for each function space
144     self.linecounts=[ (NE0+1)*(NE1+1)+1, (NE0+1)*(NE1+1)+1 ]
145     # number of masked points, i.e. where X[0] is non-zero
146     self.linecounts_masked=[ NE0*(NE1+1)+1, NE0*(NE1+1)+1 ]
147     # expected values in first line of masked data = [ X[:], X[0] ]
148     self.firstline=[ [1./NE0, 0., 1./NE0], [1./NE0, 0., 1./NE0] ]
149 jfenwick 2644
150 caltinay 3996 if getMPISizeWorld() == 1:
151     self.functionspaces += [ Function, ReducedFunction,
152     FunctionOnBoundary, ReducedFunctionOnBoundary ]
153     self.linecounts += [ 121, 41, 37, 19 ]
154     self.linecounts_masked += [ 116, 41, 27, 14 ]
155     self.firstline += [
156     [.125, 0., .125],
157     [.16666666666666667, .0666666666666667, .166666666666667],
158     [.05283121635129676, 0., .05283121635129676],
159     [.125, 0., .125]
160     ]
161     else:
162     print("Skipping some CSV tests on dudley since MPI size > 1")
163    
164 caltinay 3993 def tearDown(self):
165     del self.domain
166 jfenwick 2644
167 sshaw 4984 #@unittest.skipIf(getMPISizeWorld() > 1, "Skipping since MPI size > 1")
168 caltinay 3993 def test_csv_multiFS(self):
169 sshaw 4984 fname=os.path.join(DUDLEY_WORKDIR, "test_multifs.csv")
170     sol=Data(8,Solution(self.domain))
171     ctsfn=Data(9,ContinuousFunction(self.domain))
172     #test line 0
173     dirac=Data(-1,DiracDeltaFunctions(self.domain))
174     saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)
175     #test line 1
176     fun=Data(5,Function(self.domain))
177     rfun=Data(3,ReducedFunction(self.domain))
178     saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)
179     #test line 2
180     bound=Data(1,FunctionOnBoundary(self.domain))
181     rbound=Data(3,ReducedFunctionOnBoundary(self.domain))
182     saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)
183 caltinay 3993
184    
185 gross 983 if __name__ == '__main__':
186 sshaw 4984 run_tests(__name__, exit_on_failure=True)
187 gross 1376

Properties

Name Value
svn:mergeinfo /branches/lapack2681/finley/test/python/run_escriptOnFinley.py:2682-2741 /branches/pasowrap/dudley/test/python/run_escriptOnDudley.py:3661-3674 /branches/py3_attempt2/dudley/test/python/run_escriptOnDudley.py:3871-3891 /branches/restext/finley/test/python/run_escriptOnFinley.py:2610-2624 /branches/ripleygmg_from_3668/dudley/test/python/run_escriptOnDudley.py:3669-3791 /branches/stage3.0/finley/test/python/run_escriptOnFinley.py:2569-2590 /branches/symbolic_from_3470/dudley/test/python/run_escriptOnDudley.py:3471-3974 /branches/symbolic_from_3470/ripley/test/python/dudley/test/python/run_escriptOnDudley.py:3517-3974 /release/3.0/finley/test/python/run_escriptOnFinley.py:2591-2601 /trunk/ripley/test/python/dudley/test/python/run_escriptOnDudley.py:3480-3515

  ViewVC Help
Powered by ViewVC 1.1.26