/[escript]/trunk/escript/test/python/test_util_reduction_with_tagged_data.py
ViewVC logotype

Diff of /trunk/escript/test/python/test_util_reduction_with_tagged_data.py

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

trunk/escript/py_src/test_util_reduction_with_tagged_data.py revision 614 by elspeth, Wed Mar 22 01:37:07 2006 UTC trunk/escript/test/python/test_util_reduction_with_tagged_data.py revision 1809 by ksteube, Thu Sep 25 06:43:44 2008 UTC
# Line 1  Line 1 
1  # $Id:$  
2    ########################################################
3    #
4    # Copyright (c) 2003-2008 by University of Queensland
5    # Earth Systems Science Computational Center (ESSCC)
6    # http://www.uq.edu.au/esscc
7    #
8    # Primary Business: Queensland, Australia
9    # Licensed under the Open Software License version 3.0
10    # http://www.opensource.org/licenses/osl-3.0.php
11    #
12    ########################################################
13    
14    __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15    Earth Systems Science Computational Center (ESSCC)
16    http://www.uq.edu.au/esscc
17    Primary Business: Queensland, Australia"""
18    __license__="""Licensed under the Open Software License version 3.0
19    http://www.opensource.org/licenses/osl-3.0.php"""
20    __url__="http://www.uq.edu.au/esscc/escript-finley"
21    
22  """  """
23  test for util operations for reduction operations with tagged data  test for util operations for reduction operations with tagged data
24    
25  @remark: use see L{test_util}  @remark: use see L{test_util}
26  @var __author__: name of author  @var __author__: name of author
27    @var __copyright__: copyrights
28  @var __license__: licence agreement  @var __license__: licence agreement
29  @var __url__: url entry point on documentation  @var __url__: url entry point on documentation
30  @var __version__: version  @var __version__: version
# Line 11  test for util operations for reduction o Line 32  test for util operations for reduction o
32  """  """
33    
34  __author__="Lutz Gross, l.gross@uq.edu.au"  __author__="Lutz Gross, l.gross@uq.edu.au"
 __copyright__="""  Copyright (c) 2006 by ACcESS MNRF  
                     http://www.access.edu.au  
                 Primary Business: Queensland, Australia"""  
 __license__="""Licensed under the Open Software License version 3.0  
              http://www.opensource.org/licenses/osl-3.0.php"""  
 __url__="http://www.iservo.edu.au/esys/escript"  
 __version__="$Revision:$"  
 __date__="$Date:$"  
35    
36  import unittest  import unittest
37  import numarray  import numarray
38  from esys.escript import *  from esys.escript import *
39  from esys.escript.test_util_base import Test_util_base  from test_util_base import Test_util_base
40    
41  class Test_util_reduction_with_tagged_data(Test_util_base):  class Test_util_reduction_with_tagged_data(Test_util_base):
42     """     """
# Line 31  class Test_util_reduction_with_tagged_da Line 44  class Test_util_reduction_with_tagged_da
44     """     """
45     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
46     def test_Lsup_taggedData_rank0(self):     def test_Lsup_taggedData_rank0(self):
47        arg=Data(0.860813503322,self.functionspace)        defval=0.860813503322
48          arg=Data(defval,self.functionspace)
49        arg.setTaggedValue(1,0.086081350332)        arg.setTaggedValue(1,0.086081350332)
50        res=Lsup(arg)        res=Lsup(arg)
51        ref=0.860813503322        ref1=0.086081350332
52          ref2=0.860813503322
53        self.failUnless(isinstance(res,float),"wrong type of result.")        self.failUnless(isinstance(res,float),"wrong type of result.")
54        self.failUnless(abs(res-ref)<=self.RES_TOL*abs(ref),"wrong result")        self.failUnless(abs(res-ref1)<=self.RES_TOL*abs(ref1),"wrong result")
55          arg.setTaggedValue(2,defval)
56          res=Lsup(arg)
57          self.failUnless(abs(res-ref2)<=self.RES_TOL*abs(ref2),"wrong result")
58     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
59     def test_Lsup_taggedData_rank1(self):     def test_Lsup_taggedData_rank1(self):
60        arg=Data(numarray.array([-0.54932912559284452, 0.29396676960376178]),self.functionspace)        arg=Data(numarray.array([-0.54932912559284452, 0.29396676960376178]),self.functionspace)
# Line 103  class Test_util_reduction_with_tagged_da Line 121  class Test_util_reduction_with_tagged_da
121        self.failUnless(abs(res-ref)<=self.RES_TOL*abs(ref),"wrong result")        self.failUnless(abs(res-ref)<=self.RES_TOL*abs(ref),"wrong result")
122     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
123     def test_inf_taggedData_rank4(self):     def test_inf_taggedData_rank4(self):
124        arg=Data(numarray.array([[[[-0.28454409743308506, -0.5668179780431859, 0.94184808892377703, 0.92323038327044005], [-0.62255144042695854, 0.10076051065495695, -0.75730451262334242, 0.92747176366592243], [-0.27419623999345366, -0.2073834606691658, -0.80951479323876696, 0.7135757150367612]], [[-0.97314628579045248, 0.68637741632500915, 0.53335906255833199, 0.96086938773033026], [-0.94945339539011386, -0.81392220879720334, -0.85288194032365472, -0.16477859877633083], [-0.21874528606061738, 0.02516499720401133, -0.049189220512075194, 0.037621105958556278]]], [[[-0.047849568456701519, 0.17313004158353174, -0.73652898602638794, 0.54596512107217787], [0.53827755889057149, 0.82310276090363499, -0.28442357567638377, -0.27179900237071242], [-0.19399624326093612, -0.12349387443529247, -0.56735519289734504, -0.68464632829023375]], [[0.33637651162122606, 0.22878413048564927, -0.70679532991608829, -0.25607454879877101], [-0.29261869752827607, -0.210849838585774, -0.15002781188439474, -0.40403456108229485], [0.98194953410530106, -0.10120885200799257, -0.73197515875287644, -0.79609802011910569]]], [[[-0.25327135865022421, -0.57325273532977317, 0.81059261361542845, -0.046095046141370499], [0.96531384124283903, -0.61153728454098477, -0.97457818352675707, -0.62195519514120923], [0.69039154876488285, 0.92574092049825851, -0.16814749709359544, -0.10824422727782279]], [[-0.54851863859404215, -0.6147932835008143, -0.12084391085229162, 0.57476183090130717], [0.23951711064034398, -0.54814262685597792, 0.94406155895646182, 0.5501815266421175], [0.21626599181010975, -0.9661525769220054, 0.85862231711120418, 0.97115736784479956]]]]),self.functionspace)        defval=numarray.array([[[[-0.28454409743308506, -0.5668179780431859, 0.94184808892377703, 0.92323038327044005], [-0.62255144042695854, 0.10076051065495695, -0.75730451262334242, 0.92747176366592243], [-0.27419623999345366, -0.2073834606691658, -0.80951479323876696, 0.7135757150367612]], [[-0.97314628579045248, 0.68637741632500915, 0.53335906255833199, 0.96086938773033026], [-0.94945339539011386, -0.81392220879720334, -0.85288194032365472, -0.16477859877633083], [-0.21874528606061738, 0.02516499720401133, -0.049189220512075194, 0.037621105958556278]]], [[[-0.047849568456701519, 0.17313004158353174, -0.73652898602638794, 0.54596512107217787], [0.53827755889057149, 0.82310276090363499, -0.28442357567638377, -0.27179900237071242], [-0.19399624326093612, -0.12349387443529247, -0.56735519289734504, -0.68464632829023375]], [[0.33637651162122606, 0.22878413048564927, -0.70679532991608829, -0.25607454879877101], [-0.29261869752827607, -0.210849838585774, -0.15002781188439474, -0.40403456108229485], [0.98194953410530106, -0.10120885200799257, -0.73197515875287644, -0.79609802011910569]]], [[[-0.25327135865022421, -0.57325273532977317, 0.81059261361542845, -0.046095046141370499], [0.96531384124283903, -0.61153728454098477, -0.97457818352675707, -0.62195519514120923], [0.69039154876488285, 0.92574092049825851, -0.16814749709359544, -0.10824422727782279]], [[-0.54851863859404215, -0.6147932835008143, -0.12084391085229162, 0.57476183090130717], [0.23951711064034398, -0.54814262685597792, 0.94406155895646182, 0.5501815266421175], [0.21626599181010975, -0.9661525769220054, 0.85862231711120418, 0.97115736784479956]]]])
125          arg=Data(defval,self.functionspace)
126        arg.setTaggedValue(1,[[[[-0.44268265295180487, -0.94661739524160704, -0.58229956703493468, -0.83249621866194934], [-0.68913939538381319, -0.75804956419646286, 0.64749957799330526, 0.32616508244527531], [-0.14277223200775602, 0.74824266545401041, -0.75701815640062908, 0.27359871030382887]], [[-0.48033424095007193, -0.067929127807738965, 0.45865972622825102, -0.21732884173055611], [-0.84531291000880504, 0.83240578985878577, -0.25004340292634253, 0.21302689907942329], [0.46335645072330633, -0.10408082112144545, 0.96768118368872202, -0.14088569164618203]]], [[[0.28258575728428736, -0.45763983811002018, -0.29020353090870232, -0.35290974430439914], [0.8698073989711228, 0.99501431931359741, 0.36030715281910175, -0.27073779707934853], [-0.86095060819411717, -0.85818974539956372, 0.88449786126964258, -0.4780560878654454]], [[-0.12884556589949114, 0.46614981239408104, -0.82753211385973646, 0.71952728123859067], [-0.43573431868291923, 0.41690370693945611, -0.024901756894041061, 0.14934111352857715], [0.78047901800597619, 0.26373552686712709, -0.95380580583786689, 0.63288455897048768]]], [[[-0.94242811017558603, -0.2101877288188847, 0.91797691709730911, 0.45617540058153594], [-0.93413158750269942, -0.70238302965184563, 0.36501953522261488, -0.43956770565509551], [-0.056597755835613439, 0.41357120112496037, -0.60521324615373961, -0.2181851605833629]], [[-0.21130451442872822, 0.53289932629760295, -0.72866050065430343, -0.90245795340674695], [0.1171412044571345, -0.91170721460310178, 0.58826690518723557, -0.39254304440341792], [-0.60338068872893746, -0.40393966609543219, -0.69793709205007581, -0.50271106301761193]]]])        arg.setTaggedValue(1,[[[[-0.44268265295180487, -0.94661739524160704, -0.58229956703493468, -0.83249621866194934], [-0.68913939538381319, -0.75804956419646286, 0.64749957799330526, 0.32616508244527531], [-0.14277223200775602, 0.74824266545401041, -0.75701815640062908, 0.27359871030382887]], [[-0.48033424095007193, -0.067929127807738965, 0.45865972622825102, -0.21732884173055611], [-0.84531291000880504, 0.83240578985878577, -0.25004340292634253, 0.21302689907942329], [0.46335645072330633, -0.10408082112144545, 0.96768118368872202, -0.14088569164618203]]], [[[0.28258575728428736, -0.45763983811002018, -0.29020353090870232, -0.35290974430439914], [0.8698073989711228, 0.99501431931359741, 0.36030715281910175, -0.27073779707934853], [-0.86095060819411717, -0.85818974539956372, 0.88449786126964258, -0.4780560878654454]], [[-0.12884556589949114, 0.46614981239408104, -0.82753211385973646, 0.71952728123859067], [-0.43573431868291923, 0.41690370693945611, -0.024901756894041061, 0.14934111352857715], [0.78047901800597619, 0.26373552686712709, -0.95380580583786689, 0.63288455897048768]]], [[[-0.94242811017558603, -0.2101877288188847, 0.91797691709730911, 0.45617540058153594], [-0.93413158750269942, -0.70238302965184563, 0.36501953522261488, -0.43956770565509551], [-0.056597755835613439, 0.41357120112496037, -0.60521324615373961, -0.2181851605833629]], [[-0.21130451442872822, 0.53289932629760295, -0.72866050065430343, -0.90245795340674695], [0.1171412044571345, -0.91170721460310178, 0.58826690518723557, -0.39254304440341792], [-0.60338068872893746, -0.40393966609543219, -0.69793709205007581, -0.50271106301761193]]]])
127        res=inf(arg)        res=inf(arg)
128        ref=-0.974578183527        ref1=-0.953805805838  # There is a lower value in default but the tags in use prevent it being processed
129          ref2=-0.974578183527
130        self.failUnless(isinstance(res,float),"wrong type of result.")        self.failUnless(isinstance(res,float),"wrong type of result.")
131        self.failUnless(abs(res-ref)<=self.RES_TOL*abs(ref),"wrong result")        self.failUnless(abs(res-ref1)<=self.RES_TOL*abs(ref1),"wrong result")
132          arg.setTaggedValue(2,defval)
133          res=inf(arg)
134          self.failUnless(abs(res-ref2)<=self.RES_TOL*abs(ref2),"wrong result")
135     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
136     def test_sup_taggedData_rank0(self):     def test_sup_taggedData_rank0(self):
137        arg=Data(0.649634736435,self.functionspace)        arg=Data(0.649634736435,self.functionspace)
# Line 143  class Test_util_reduction_with_tagged_da Line 166  class Test_util_reduction_with_tagged_da
166        self.failUnless(abs(res-ref)<=self.RES_TOL*abs(ref),"wrong result")        self.failUnless(abs(res-ref)<=self.RES_TOL*abs(ref),"wrong result")
167     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
168     def test_sup_taggedData_rank4(self):     def test_sup_taggedData_rank4(self):
169        arg=Data(numarray.array([[[[0.65078702842768221, -0.73900875462993776, -0.65984653996722176, -0.97539191158251093], [0.99720731720088596, -0.19242629799409516, -0.16320360691406655, -0.043083875914333492], [0.59108757025274139, 0.88522336612612706, 0.74088460755604268, 0.80676177752104627]], [[0.82498945289642323, 0.23110039892583623, -0.13089698664065774, -0.400241064232296], [-0.67523171276117, -0.72699269118844501, 0.53208807038398409, -0.49611668096456474], [-0.20482996861953673, 0.83614314521551858, -0.82232394050773272, -0.71904026227092044]]], [[[0.34003140388599551, 0.31905118515154363, 0.51883291903272832, -0.76898011700894209], [-0.00054352334236540401, -0.42459032663080087, 0.72331023817772211, -0.50647033418441123], [0.76195696335445318, -0.22666337528546276, -0.40740135145605061, -0.81651333897992373]], [[-0.9819499586934739, -0.95616911480063527, -0.2900474363658565, -0.16636609538100222], [0.66435123810546681, -0.30523563374854135, -0.21355210817886849, -0.74243246288718034], [0.82105586828161425, -0.93524621329362057, 0.36308161224720026, 0.76840492117538539]]], [[[-0.22872302699935965, 0.047300841535470761, -0.93216772922157576, -0.40541971639813301], [0.22921538079079262, 0.1958937804621288, 0.27198494374967619, 0.55888236453433282], [0.97179646000620856, 0.53691052552944973, -0.13695340427959324, -0.10499588580374764]], [[-0.4821448283439782, -0.96593591454069139, -0.95284453814535297, -0.35311046977499583], [0.4857495870271038, -0.66584818036412852, -0.04957796396188785, 0.28223147859593767], [-0.2171789936962405, -0.016212404435609562, 0.16258357268143042, -0.6781166044152207]]]]),self.functionspace)        defval=numarray.array([[[[0.65078702842768221, -0.73900875462993776, -0.65984653996722176, -0.97539191158251093], [0.99720731720088596, -0.19242629799409516, -0.16320360691406655, -0.043083875914333492], [0.59108757025274139, 0.88522336612612706, 0.74088460755604268, 0.80676177752104627]], [[0.82498945289642323, 0.23110039892583623, -0.13089698664065774, -0.400241064232296], [-0.67523171276117, -0.72699269118844501, 0.53208807038398409, -0.49611668096456474], [-0.20482996861953673, 0.83614314521551858, -0.82232394050773272, -0.71904026227092044]]], [[[0.34003140388599551, 0.31905118515154363, 0.51883291903272832, -0.76898011700894209], [-0.00054352334236540401, -0.42459032663080087, 0.72331023817772211, -0.50647033418441123], [0.76195696335445318, -0.22666337528546276, -0.40740135145605061, -0.81651333897992373]], [[-0.9819499586934739, -0.95616911480063527, -0.2900474363658565, -0.16636609538100222], [0.66435123810546681, -0.30523563374854135, -0.21355210817886849, -0.74243246288718034], [0.82105586828161425, -0.93524621329362057, 0.36308161224720026, 0.76840492117538539]]], [[[-0.22872302699935965, 0.047300841535470761, -0.93216772922157576, -0.40541971639813301], [0.22921538079079262, 0.1958937804621288, 0.27198494374967619, 0.55888236453433282], [0.97179646000620856, 0.53691052552944973, -0.13695340427959324, -0.10499588580374764]], [[-0.4821448283439782, -0.96593591454069139, -0.95284453814535297, -0.35311046977499583], [0.4857495870271038, -0.66584818036412852, -0.04957796396188785, 0.28223147859593767], [-0.2171789936962405, -0.016212404435609562, 0.16258357268143042, -0.6781166044152207]]]])
170          arg=Data(defval,self.functionspace)
171        arg.setTaggedValue(1,[[[[0.80768589260978896, -0.22702941364663487, -0.72896606223385407, 0.11413326357409237], [0.40571664072592251, -0.9311405487001907, 0.80450361552618688, 0.56480640933432991], [-0.33782609968052979, 0.39512515837757123, 0.73591694462004398, 0.24768959674737778]], [[0.56569618270183164, -0.93779341659685, 0.64969642196738708, -0.77336556098096976], [0.41311175212178153, 0.056953746906872826, 0.25300968955971204, -0.35019321925911262], [-0.8863122403302417, -0.89705763853428677, 0.3060047535556778, -0.92592167036041095]]], [[[0.45649019646929379, -0.29843125838513096, -0.20714508244855367, 0.246705639144563], [-0.32477747411703084, 0.30488751585973306, 0.53390827733820756, -0.84339943975046583], [-0.12373671376305295, -0.1640054521913612, -0.87414144472044897, -0.0021211693404443732]], [[0.38273461960506805, 0.70999974995969617, 0.22361687978370237, -0.098549468178965371], [0.81724211804899904, -0.88965787513620009, -0.39375673885748119, 0.69490920308416371], [-0.65400552410197754, -0.82376412930222931, 0.046545365304690778, -0.21012949605343434]]], [[[-0.27643919361415081, -0.44880727610691973, -0.57364607821939151, -0.14013355075911993], [-0.99302452440223621, 0.70400083788517742, 0.29183091261608896, 0.57457780218190213], [0.20084128112884403, 0.98904695078892235, 0.87503585272015294, -0.26131933340055569]], [[0.94633204265993198, -0.73295197510079446, 0.56975658926329098, -0.83390352955122538], [0.2617682886960544, 0.14649180808291562, -0.29972426982703726, -0.015848496464521356], [-0.96680270201151153, -0.79982829582732196, -0.29552300849179347, 0.66620264190912515]]]])        arg.setTaggedValue(1,[[[[0.80768589260978896, -0.22702941364663487, -0.72896606223385407, 0.11413326357409237], [0.40571664072592251, -0.9311405487001907, 0.80450361552618688, 0.56480640933432991], [-0.33782609968052979, 0.39512515837757123, 0.73591694462004398, 0.24768959674737778]], [[0.56569618270183164, -0.93779341659685, 0.64969642196738708, -0.77336556098096976], [0.41311175212178153, 0.056953746906872826, 0.25300968955971204, -0.35019321925911262], [-0.8863122403302417, -0.89705763853428677, 0.3060047535556778, -0.92592167036041095]]], [[[0.45649019646929379, -0.29843125838513096, -0.20714508244855367, 0.246705639144563], [-0.32477747411703084, 0.30488751585973306, 0.53390827733820756, -0.84339943975046583], [-0.12373671376305295, -0.1640054521913612, -0.87414144472044897, -0.0021211693404443732]], [[0.38273461960506805, 0.70999974995969617, 0.22361687978370237, -0.098549468178965371], [0.81724211804899904, -0.88965787513620009, -0.39375673885748119, 0.69490920308416371], [-0.65400552410197754, -0.82376412930222931, 0.046545365304690778, -0.21012949605343434]]], [[[-0.27643919361415081, -0.44880727610691973, -0.57364607821939151, -0.14013355075911993], [-0.99302452440223621, 0.70400083788517742, 0.29183091261608896, 0.57457780218190213], [0.20084128112884403, 0.98904695078892235, 0.87503585272015294, -0.26131933340055569]], [[0.94633204265993198, -0.73295197510079446, 0.56975658926329098, -0.83390352955122538], [0.2617682886960544, 0.14649180808291562, -0.29972426982703726, -0.015848496464521356], [-0.96680270201151153, -0.79982829582732196, -0.29552300849179347, 0.66620264190912515]]]])
172        res=sup(arg)        res=sup(arg)
173        ref=0.997207317201        ref1=0.989046950789
174          ref2=0.997207317201
175        self.failUnless(isinstance(res,float),"wrong type of result.")        self.failUnless(isinstance(res,float),"wrong type of result.")
176        self.failUnless(abs(res-ref)<=self.RES_TOL*abs(ref),"wrong result")        self.failUnless(abs(res-ref1)<=self.RES_TOL*abs(ref1),"wrong result")
177          arg.setTaggedValue(2,defval);
178          res=sup(arg)
179          self.failUnless(abs(res-ref2)<=self.RES_TOL*abs(ref2),"wrong result")
180    
181    

Legend:
Removed from v.614  
changed lines
  Added in v.1809

  ViewVC Help
Powered by ViewVC 1.1.26