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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4984 - (show annotations)
Mon Jun 2 02:50:34 2014 UTC (4 years, 10 months ago) by sshaw
File MIME type: text/x-python
File size: 19715 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
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2014 by University of Queensland
5 # http://www.uq.edu.au
6 #
7 # 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 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 import os
25 import sys
26 import esys.escriptcore.utestselect as unittest
27 from esys.escriptcore.testing import *
28 from esys.escript import *
29 from esys.finley import Rectangle, Brick, ReadMesh, ReadGmsh
30 from test_objects import Test_Dump, Test_SetDataPointValue, Test_saveCSV, \
31 Test_TableInterpolation, Test_Domain, Test_GlobalMinMax, Test_Lazy
32 from test_shared import Test_Shared
33
34 try:
35 FINLEY_WORKDIR=os.environ['FINLEY_WORKDIR']
36 except KeyError:
37 FINLEY_WORKDIR='.'
38
39
40 try:
41 FINLEY_TEST_DATA=os.environ['FINLEY_TEST_DATA']
42 except KeyError:
43 FINLEY_TEST_DATA='.'
44
45 FINLEY_TEST_MESH_PATH=os.path.join(FINLEY_TEST_DATA,"data_meshes")
46
47 mpisize=getMPISizeWorld()
48 NE=4 # number elements, must be even
49
50 class Test_SharedOnFinley(Test_Shared):
51 def setUp(self):
52 self.domain=Rectangle(NE,NE)
53 self.tol=0.001
54
55 def tearDown(self):
56 del self.domain
57 del self.tol
58
59 class Test_DomainOnFinley(Test_Domain):
60 def setUp(self):
61 self.boundary_tag_list = [1, 2, 10, 20]
62 self.domain =Rectangle(NE,NE+1,2)
63 self.rdomain=self.domain
64
65 def tearDown(self):
66 del self.domain
67 del self.rdomain
68 del self.boundary_tag_list
69
70 def test_setXError(self):
71 domain=Rectangle(NE,NE)
72 x=domain.getX()
73 z=interpolate(x, Function(domain))
74 self.assertRaises(RuntimeError, domain.setX, z)
75 del x
76 del z
77 del domain
78
79 def test_tagsContinuousFunction(self):
80 ref_tags=[0]
81 tags=ContinuousFunction(self.domain).getListOfTags()
82 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
83 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
84
85 def test_tagsFunction(self):
86 ref_tags=[0]
87 tags=Function(self.domain).getListOfTags()
88 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
89 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
90 def test_tagsReducedFunction(self):
91 ref_tags=[0]
92 tags=ReducedFunction(self.domain).getListOfTags()
93 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
94 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
95 def test_tagsFunctionOnBoundary(self):
96 ref_tags=[1, 2, 10, 20]
97 tags=FunctionOnBoundary(self.domain).getListOfTags()
98 # For an MPI-distributed domain some tags may be missing
99 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 def test_tagsReducedFunctionOnBoundary(self):
102 ref_tags=[1, 2, 10, 20]
103 tags=ReducedFunctionOnBoundary(self.domain).getListOfTags()
104 # For an MPI-distributed domain some tags may be missing
105 if getMPISizeWorld() == 1: self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
106 for i in tags: self.assertTrue(i in ref_tags,"tag %s is missing."%i)
107 def test_tagsFunctionOnContactOne(self):
108 ref_tags=[]
109 tags=FunctionOnContactOne(self.domain).getListOfTags()
110 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
111 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
112 def test_tagsFunctionOnContactZero(self):
113 ref_tags=[]
114 tags=FunctionOnContactZero(self.domain).getListOfTags()
115 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
116 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
117 def test_tagsReducedFunctionOnContactOne(self):
118 ref_tags=[]
119 tags=ReducedFunctionOnContactOne(self.domain).getListOfTags()
120 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
121 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
122 def test_tagsReducedFunctionOnContactZero(self):
123 ref_tags=[]
124 tags=ReducedFunctionOnContactZero(self.domain).getListOfTags()
125 self.assertTrue(len(tags)==len(ref_tags), "tags list has wrong length.")
126 for i in ref_tags: self.assertTrue(i in tags,"tag %s is missing."%i)
127
128 class Test_DataOpsOnFinley(Test_Dump, Test_SetDataPointValue, Test_GlobalMinMax, Test_Lazy):
129 def setUp(self):
130 self.domain =Rectangle(NE,NE+1,2)
131 self.domain_with_different_number_of_samples =Rectangle(2*NE,NE+1,2)
132 self.domain_with_different_number_of_data_points_per_sample =Rectangle(2*NE,NE+1,2,integrationOrder=2)
133 self.domain_with_different_sample_ordering =Rectangle(NE,NE+1,2, optimize=True)
134 self.filename_base=FINLEY_WORKDIR
135 self.mainfs=Function(self.domain)
136 self.otherfs=Solution(self.domain)
137
138 def tearDown(self):
139 del self.domain
140 del self.domain_with_different_number_of_samples
141 del self.domain_with_different_number_of_data_points_per_sample
142 del self.domain_with_different_sample_ordering
143 del self.mainfs
144 del self.otherfs
145
146
147 class Test_TableInterpolationOnFinley(Test_TableInterpolation):
148 def setUp(self):
149 self.domain=Brick(4,4,4)
150 self.functionspaces=[ContinuousFunction(self.domain), Function(self.domain), ReducedFunction(self.domain),
151 FunctionOnBoundary(self.domain), ReducedFunctionOnBoundary(self.domain),
152 FunctionOnContactZero(self.domain), FunctionOnContactOne(self.domain),
153 ReducedFunctionOnContactZero(self.domain), ReducedFunctionOnContactOne(self.domain)]
154 #We aren't testing DiracDeltaFunctions
155 self.xn=3 # number of grids on x axis
156 self.yn=3 # number of grids on y axis
157 self.zn=3 # number of grids on z axis
158
159 def tearDown(self):
160 del self.domain
161 del self.functionspaces
162
163
164 #This functionality is only testes on Finley.
165 #It is not finley specific but it does need a known set of input points so I've chosen to put it here
166 class Test_OtherInterpolationOnFinley(unittest.TestCase):
167 def setUp(self):
168 self.r=Rectangle(4,1).getX()[0]+2
169 self.z=Data(2)
170
171 def tearDown(self):
172 del self.z
173 del self.r
174
175 def test_nonuniformint(self):
176 self.assertRaises(RuntimeError, self.z.nonuniformInterpolate, [0,1], [5,6], True)
177 self.assertRaises(RuntimeError, self.z.nonuniformInterpolate, [3,4], [5,6], True)
178 self.assertTrue(Lsup(self.z.nonuniformInterpolate([0,1], [5,6], False)-6)<0.00001, "RHS edge not fitted")
179 self.assertTrue(Lsup(self.z.nonuniformInterpolate([3,4], [5,6], False)-5)<0.00001, "LHS edge not fitted")
180 tmp=self.r.nonuniformInterpolate([2.125, 2.4, 2.5, 2.8], [1, -1, 2, 4], False)
181 self.assertTrue(Lsup(sup(tmp)-4)<0.0001, "RHS edge not fitted for Rect")
182 self.assertTrue(Lsup(inf(tmp)-0.090909)<0.00001, "Internal interpolate failed")
183 tmp=self.r.nonuniformInterpolate([2.125, 2.4, 2.5, 3.2], [1, -1, 2, 4], False)
184 self.assertTrue(Lsup(sup(tmp)-3.42857)<0.00001, "Internal interpolate failed")
185
186 def test_nonuniformSlope(self):
187 self.assertRaises(RuntimeError, self.z.nonuniformSlope, [0,1], [5,6], True)
188 self.assertRaises(RuntimeError, self.z.nonuniformSlope, [3,4], [5,6], True)
189 self.assertTrue(Lsup(self.z.nonuniformSlope([0,1], [5,6], False))<0.00001, "RHS edge not fitted")
190 self.assertTrue(Lsup(self.z.nonuniformSlope([3,4], [5,6], False))<0.00001, "LHS edge not fitted")
191 tmp=self.r.nonuniformSlope([2.125, 2.4, 2.5, 3.2], [1, -1, 2, 4], False)
192 self.assertTrue(Lsup(sup(tmp)-30)<0.00001, "Internal interpolate failed")
193 self.assertTrue(Lsup(inf(tmp)+7.27273)<0.00001, "Internal interpolate failed")
194
195 class Test_CSVOnFinley(Test_saveCSV):
196 def setUp(self):
197 NE0=NE
198 NE1=NE+1
199 self.domain = Rectangle(NE0, NE1, order=2)
200 self.functionspaces = [ ContinuousFunction ]
201 # number of total data points for each function space
202 self.linecounts=[ (2*NE0+1)*(2*NE1+1)-NE0*NE1+1 ]
203 # number of masked points, i.e. where X[0] is non-zero
204 self.linecounts_masked=[ (2*NE0+1)*(2*NE1+1)-(2+NE0)*NE1 ]
205 # expected values in first line of masked data = [ X[:], X[0] ]
206 self.firstline=[ [1./(2*NE0), 0., 1./(2*NE0)] ]
207
208 if getMPISizeWorld() == 1:
209 self.functionspaces += [ ReducedContinuousFunction, Function,
210 ReducedFunction, FunctionOnBoundary, ReducedFunctionOnBoundary ]
211 self.linecounts += [ 31, 181, 81, 55, 37 ]
212 self.linecounts_masked += [ 25, 181, 81, 40, 27 ]
213 self.firstline += [ [.25, 0., .25],
214 [.02817541634481463,.02254033307585171,.02817541634481463],
215 [.05283121635129676,.04226497308103741,.05283121635129676],
216 [.02817541634481463,0.,.02817541634481463],
217 [.05283121635129676,0.,.05283121635129676]
218 ]
219 else:
220 print("Skipping some CSV tests on finley since MPI size > 1")
221
222 def tearDown(self):
223 del self.domain
224
225 @unittest.skipIf(mpisize>1, "more than 1 MPI rank")
226 def test_csv_multiFS(self):
227 fname=os.path.join(FINLEY_WORKDIR, "test_multifs.csv")
228 sol=Data(8,Solution(self.domain))
229 ctsfn=Data(9,ContinuousFunction(self.domain))
230 #test line 0
231 dirac=Data(-1,DiracDeltaFunctions(self.domain))
232 saveDataCSV(fname, A=sol, B=ctsfn, C=dirac)
233 #test line 1
234 fun=Data(5,Function(self.domain))
235 rfun=Data(3,ReducedFunction(self.domain))
236 saveDataCSV(fname, A=sol,B=ctsfn,C=fun, D=rfun)
237 #test line 2
238 bound=Data(1,FunctionOnBoundary(self.domain))
239 rbound=Data(3,ReducedFunctionOnBoundary(self.domain))
240 saveDataCSV(fname,A=sol,B=ctsfn,C=bound, D=rbound)
241 #test line 3
242 conzz=Data(7,FunctionOnContactZero(self.domain))
243 rconz=Data(8,ReducedFunctionOnContactZero(self.domain))
244 saveDataCSV(fname,A=sol,B=ctsfn, C=conzz, D=rconz)
245 #check for cross line exceptions
246 self.assertRaises(RuntimeError, saveDataCSV, fname, A=dirac, B=rfun)
247 self.assertRaises(RuntimeError, saveDataCSV, fname, A=bound, B=conzz)
248
249
250 class Test_DiracOnFinley(unittest.TestCase):
251 def test_rectconstr(self):
252 self.assertRaises(RuntimeError, Rectangle, 4,4, diracPoints=[(0,0)])
253 self.assertRaises(RuntimeError, Rectangle, 4,4, diracPoints=[(0,0), (1,1)], diracTags=[40])
254 self.assertRaises(RuntimeError, Rectangle, 4,4, diracPoints=[(0,0), (1,1)], diracTags=[40])
255 self.assertRaises(RuntimeError, Rectangle, 4,4, diracPoints=[(0,0), (1,1)], diracTags=["cows"])
256 self.assertRaises(RuntimeError, Rectangle, 4,4, diracPoints=[(0,)], diracTags=["test"])
257 z=Rectangle(4,4, diracPoints=[(0,0), (0.25,0.25)], diracTags=[40,51])
258 z=Rectangle(4,4, diracPoints=[(0.125,0.625), (0.5,1), (0.75, 0.25), (0.89, 0.875)], diracTags=["A", "B", "A", "C"])
259 v=interpolate(z.getX(), DiracDeltaFunctions(z))
260 if mpisize==1:
261 self.assertEquals(v.toListOfTuples(),[(0.0, 0.5), (0.5, 1.0), (0.75, 0.25), (1.0, 0.75)])
262 self.assertEquals(v.getNumberOfDataPoints(), 4)
263 self.assertEquals(inf(v[0]), 0)
264 self.assertEquals(inf(v[1]), 0.25)
265 self.assertEquals(Lsup(v[0]), 1)
266 self.assertEquals(Lsup(v[1]), 1)
267 v.setTaggedValue("A",(-10,0.5))
268 if mpisize==1:
269 self.assertEquals(inf(v[0]), -10)
270 self.assertEquals(inf(v[1]), 0.5)
271 v.setTaggedValue(500,(-100,-100)) # non-existant tag
272 if mpisize==1:
273 self.assertEquals(inf(v[0]), -10)
274 self.assertEquals(inf(v[1]), 0.5)
275 self.assertEquals(z.showTagNames(), 'A, B, C, bottom, left, right, top')
276 self.assertEquals(z.getTag("C"), 42)
277
278 def test_brickconstr(self):
279 self.assertRaises(RuntimeError, Brick, 4,4, diracPoints=[(0,0,0)])
280 self.assertRaises(RuntimeError, Brick, 4,4, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40])
281 self.assertRaises(RuntimeError, Brick, 4,4, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40])
282 self.assertRaises(RuntimeError, Brick, 4,4, diracPoints=[(0,0,0), (1,1,1)], diracTags=["cows"])
283 self.assertRaises(RuntimeError, Brick, 4,4, diracPoints=[(0,0)], diracTags=["test"])
284 z=Brick(4,4, diracPoints=[(0,0,0), (0.25,0.25, 0.25)], diracTags=[40,51])
285 z=Brick(4,4, diracPoints=[(0.125,0.625,0), (0.5,1,0), (0.75, 0.25, 0.51), (0.89, 0.875,1)], diracTags=["A", "B", "A", "C"])
286 v=interpolate(z.getX(), DiracDeltaFunctions(z))
287 if mpisize==1:
288 self.assertEquals(v.toListOfTuples(),[(0.0, 0.5, 0.0), (0.5, 1.0, 0.0), (0.75, 0.25, 1), (1.0, 0.75, 1.0)])
289 self.assertEquals(v.getNumberOfDataPoints(), 4)
290 self.assertEquals(inf(v[0]), 0)
291 self.assertEquals(inf(v[1]), 0.25)
292 self.assertEquals(Lsup(v[0]), 1)
293 self.assertEquals(Lsup(v[1]), 1)
294 v.setTaggedValue("A",(-10,0.5,-500))
295 if mpisize==1:
296 self.assertEquals(inf(v[0]), -10)
297 self.assertEquals(inf(v[1]), 0.5)
298 self.assertEquals(inf(v[2]),-500)
299 v.setTaggedValue(500,(-100,-100, -100)) # non-existant tag
300 if mpisize==1:
301 self.assertEquals(inf(v[0]), -10)
302 self.assertEquals(inf(v[1]), 0.5)
303 self.assertEquals(z.showTagNames(), 'A, B, C, back, bottom, front, left, right, top')
304 self.assertEquals(z.getTag("C"), 42)
305
306
307 def test_rectReadMesh(self):
308 fname=os.path.join(FINLEY_TEST_MESH_PATH,'rect_4x4.fly')
309 self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,)])
310 self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0)])
311 self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0), (1,1)], diracTags=[40])
312 self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0), (1,1)], diracTags=["cows"])
313 z=ReadMesh(fname, diracPoints=[(0,0), (0.25,0.25)], diracTags=[40,51])
314 z=ReadMesh(fname, diracPoints=[(0.125,0.625), (0.5,1), (0.75, 0.25), (0.89, 0.875)], diracTags=["A", "B", "A", "C"])
315 v=interpolate(z.getX(), DiracDeltaFunctions(z))
316 if mpisize==1:
317 self.assertEquals(v.toListOfTuples(),[(0.0, 0.5), (0.5, 1.0), (0.75, 0.25), (1.0, 0.75)])
318 self.assertEquals(v.getNumberOfDataPoints(), 4)
319 self.assertEquals(inf(v[0]), 0)
320 self.assertEquals(inf(v[1]), 0.25)
321 self.assertEquals(Lsup(v[0]), 1)
322 self.assertEquals(Lsup(v[1]), 1)
323 v.setTaggedValue("A",(-10,0.5))
324 if mpisize==1:
325 self.assertEquals(inf(v[0]), -10)
326 self.assertEquals(inf(v[1]), 0.5)
327 v.setTaggedValue(500,(-100,-100)) # non-existant tag
328 if mpisize==1:
329 self.assertEquals(inf(v[0]), -10)
330 self.assertEquals(inf(v[1]), 0.5)
331 self.assertEquals(z.showTagNames(), 'A, B, C, bottom, left, right, top')
332 self.assertEquals(z.getTag("C"), 42)
333
334
335 def test_brickReadMesh(self):
336 fname=os.path.join(FINLEY_TEST_MESH_PATH,'brick_4x4x4.fly')
337 self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0)])
338 self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0,0)])
339 self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40])
340 self.assertRaises(RuntimeError, ReadMesh, fname, diracPoints=[(0,0,0), (1,1,1)], diracTags=["cows"])
341 z=ReadMesh(fname, diracPoints=[(0,0,1), (0.25,0.25, 0.25)], diracTags=[40,51])
342 z=ReadMesh(fname, diracPoints=[(0.125,0.625,0), (0.5,1,1), (0.75, 0.25,0), (0.89, 0.875, 0.5)], diracTags=["A", "B", "A", "C"])
343 v=interpolate(z.getX(), DiracDeltaFunctions(z))
344 if mpisize==1:
345 self.assertEquals(v.toListOfTuples(),[(0.0, 0.5, 0.0), (0.5, 1.0, 1.0), (0.75, 0.25, 0.0), (1.0, 0.75, 0.5)])
346 self.assertEquals(v.getNumberOfDataPoints(), 4)
347 self.assertEquals(inf(v[0]), 0)
348 self.assertEquals(inf(v[1]), 0.25)
349 self.assertEquals(Lsup(v[0]), 1)
350 self.assertEquals(Lsup(v[1]), 1)
351 v.setTaggedValue("A",(-10,0.5,-0.5))
352 if mpisize==1:
353 self.assertEquals(inf(v[0]), -10)
354 self.assertEquals(inf(v[1]), 0.5)
355 self.assertEquals(inf(v[2]), -0.5)
356 v.setTaggedValue(500,(-100,-100, -100)) # non-existant tag
357 if mpisize==1:
358 self.assertEquals(inf(v[0]), -10)
359 self.assertEquals(inf(v[1]), 0.5)
360 self.assertEquals(inf(v[2]), -0.5)
361 self.assertEquals(z.showTagNames(), 'A, B, C, back, bottom, front, left, right, top')
362 self.assertEquals(z.getTag("C"), 203)
363
364
365
366 @unittest.skipIf(mpisize>1, "more than 1 MPI rank")
367 def test_rectReadGmsh(self):
368 fname=os.path.join(FINLEY_TEST_MESH_PATH, 'rect_test.msh')
369 self.assertRaises(RuntimeError, ReadGmsh, fname, 2, diracPoints=[(0,0)])
370 self.assertRaises(RuntimeError, ReadGmsh, fname, 2, diracPoints=[(0,0), (1,1)], diracTags=[40])
371 self.assertRaises(RuntimeError, ReadGmsh, fname, 2, diracPoints=[(0,0), (1,1)], diracTags=["cows"])
372 z=ReadGmsh(fname, 2, diracPoints=[(0,0), (1,1)], diracTags=[40,51])
373 z=ReadGmsh(fname, 2, diracPoints=[(0,0),(0,1),(1,0),(1,1)], diracTags=["A", "B", "A", "C"])
374 v=interpolate(z.getX(), DiracDeltaFunctions(z))
375 if mpisize==1:
376 self.assertEquals(v.toListOfTuples(),[(0,0), (0,1), (1,0), (1,1)])
377 self.assertEquals(v.getNumberOfDataPoints(), 4)
378 v.setTaggedValue("A",(-10,99))
379 self.assertEquals(inf(v[0]), -10)
380 self.assertEquals(Lsup(v[1]), 99)
381 v.setTaggedValue(500,(-100,-100)) # non-existant tag
382 self.assertEquals(inf(v[0]), -10)
383 self.assertEquals(Lsup(v[1]), 99)
384 self.assertEquals(z.showTagNames(), 'A, B, C')
385 self.assertEquals(z.getTag("C"), 42)
386
387 @unittest.skipIf(mpisize>1, "more than 1 MPI rank")
388 def test_brickReadGmsh(self):
389 fname=os.path.join(FINLEY_TEST_MESH_PATH, 'brick_test.msh')
390 self.assertRaises(RuntimeError, ReadGmsh, fname, 3, diracPoints=[(0,0)])
391 self.assertRaises(RuntimeError, ReadGmsh, fname, 3, diracPoints=[(0,0,0)])
392 self.assertRaises(RuntimeError, ReadGmsh, fname, 3, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40])
393 self.assertRaises(RuntimeError, ReadGmsh, fname, 3, diracPoints=[(0,0,0), (1,1,1)], diracTags=["cows"])
394 z=ReadGmsh(fname, 3, diracPoints=[(0,0,0), (1,1,1)], diracTags=[40,51])
395 z=ReadGmsh(fname, 3, diracPoints=[(0,0,0),(0,1,0),(1,0,1),(1,1,1)], diracTags=["A", "B", "A", "C"])
396 v=interpolate(z.getX(), DiracDeltaFunctions(z))
397 if mpisize==1:
398 self.assertEquals(v.toListOfTuples(),[(0,0,0), (0,1,0), (1,0,1), (1,1,1)])
399 self.assertEquals(v.getNumberOfDataPoints(), 4)
400 v.setTaggedValue("A",(-10,99,-98))
401 self.assertEquals(inf(v[0]), -10)
402 self.assertEquals(Lsup(v[1]), 99)
403 self.assertEquals(inf(v[2]), -98)
404 v.setTaggedValue(500,(-100,-100,-100)) # non-existant tag
405 self.assertEquals(inf(v[0]), -10)
406 self.assertEquals(Lsup(v[1]), 99)
407 self.assertEquals(z.showTagNames(), 'A, B, C')
408 self.assertEquals(z.getTag("C"), 42)
409
410
411 if __name__ == '__main__':
412 run_tests(__name__, exit_on_failure=True)
413

  ViewVC Help
Powered by ViewVC 1.1.26