/[escript]/trunk/weipa/test/python/run_savevtk_tests.py
ViewVC logotype

Diff of /trunk/weipa/test/python/run_savevtk_tests.py

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

revision 3774 by caltinay, Tue Oct 11 03:59:40 2011 UTC revision 3775 by jfenwick, Wed Jan 18 07:26:34 2012 UTC
# Line 79  class VTKParser(): Line 79  class VTKParser():
79          points = self.doc.getElementsByTagName('Points')[0]          points = self.doc.getElementsByTagName('Points')[0]
80          array = points.childNodes[0]          array = points.childNodes[0]
81          nComp = int(array.getAttribute('NumberOfComponents'))          nComp = int(array.getAttribute('NumberOfComponents'))
82          flatlist = map(float, array.childNodes[0].data.split())          flatlist = list(map(float, array.childNodes[0].data.split()))
83          return [flatlist[i:i+nComp] for i in range(0,len(flatlist),nComp)]          return [flatlist[i:i+nComp] for i in range(0,len(flatlist),nComp)]
84    
85      def getCellConnectivity(self):      def getCellConnectivity(self):
# Line 87  class VTKParser(): Line 87  class VTKParser():
87          cells = self.doc.getElementsByTagName('Cells')[0]          cells = self.doc.getElementsByTagName('Cells')[0]
88          for d in cells.childNodes:          for d in cells.childNodes:
89              if d.getAttribute('Name')=='connectivity':              if d.getAttribute('Name')=='connectivity':
90                  conn = map(int, d.childNodes[0].data.split())                  conn = list(map(int, d.childNodes[0].data.split()))
91          return conn          return conn
92    
93      def getCellOffsets(self):      def getCellOffsets(self):
# Line 95  class VTKParser(): Line 95  class VTKParser():
95          cells = self.doc.getElementsByTagName('Cells')[0]          cells = self.doc.getElementsByTagName('Cells')[0]
96          for d in cells.childNodes:          for d in cells.childNodes:
97              if d.getAttribute('Name')=='offsets':              if d.getAttribute('Name')=='offsets':
98                  offsets = map(int, d.childNodes[0].data.split())                  offsets = list(map(int, d.childNodes[0].data.split()))
99          return offsets          return offsets
100    
101      def getCellTypes(self):      def getCellTypes(self):
# Line 103  class VTKParser(): Line 103  class VTKParser():
103          cells = self.doc.getElementsByTagName('Cells')[0]          cells = self.doc.getElementsByTagName('Cells')[0]
104          for d in cells.childNodes:          for d in cells.childNodes:
105              if d.getAttribute('Name')=='types':              if d.getAttribute('Name')=='types':
106                  types = map(int, d.childNodes[0].data.split())                  types = list(map(int, d.childNodes[0].data.split()))
107          return types          return types
108    
109      def getPointData(self):      def getPointData(self):
# Line 113  class VTKParser(): Line 113  class VTKParser():
113              for d in pdata[0].childNodes:              for d in pdata[0].childNodes:
114                  if d.hasChildNodes():                  if d.hasChildNodes():
115                      nComp = int(d.getAttribute('NumberOfComponents'))                      nComp = int(d.getAttribute('NumberOfComponents'))
116                      flatlist = map(float, d.childNodes[0].data.split())                      flatlist = list(map(float, d.childNodes[0].data.split()))
117                      if nComp==1:                      if nComp==1:
118                          data[d.getAttribute('Name')] = flatlist                          data[d.getAttribute('Name')] = flatlist
119                      else:                      else:
# Line 128  class VTKParser(): Line 128  class VTKParser():
128              for d in cdata[0].childNodes:              for d in cdata[0].childNodes:
129                  if d.hasChildNodes():                  if d.hasChildNodes():
130                      nComp = int(d.getAttribute('NumberOfComponents'))                      nComp = int(d.getAttribute('NumberOfComponents'))
131                      flatlist = map(float, d.childNodes[0].data.split())                      flatlist = list(map(float, d.childNodes[0].data.split()))
132                      if nComp==1:                      if nComp==1:
133                          data[d.getAttribute('Name')] = flatlist                          data[d.getAttribute('Name')] = flatlist
134                      else:                      else:
# Line 157  class Test_VTKSaver(unittest.TestCase): Line 157  class Test_VTKSaver(unittest.TestCase):
157      def compareDataWithMap(self, d1, d2, indexMap):      def compareDataWithMap(self, d1, d2, indexMap):
158          if len(d1) != len(d2): return False          if len(d1) != len(d2): return False
159          for i in range(len(d1)):          for i in range(len(d1)):
160              if indexMap.has_key(i):              if i in indexMap:
161                  jlist=indexMap[i]                  jlist=indexMap[i]
162                  if type(d1[i])==list:                  if type(d1[i])==list:
163                      if not max([ self.numericCompareL2(d1[i], d2[j]) for j in jlist ]):                      if not max([ self.numericCompareL2(d1[i], d2[j]) for j in jlist ]):
# Line 239  class Test_VTKSaver(unittest.TestCase): Line 239  class Test_VTKSaver(unittest.TestCase):
239          pdata2=p2.getPointData()          pdata2=p2.getPointData()
240          self.assertEquals(len(pdata1), len(pdata2))          self.assertEquals(len(pdata1), len(pdata2))
241          for name in pdata2:          for name in pdata2:
242              self.assertTrue(pdata1.has_key(name), "Point variable '%s' missing"%name)              self.assertTrue(name in pdata1, "Point variable '%s' missing"%name)
243              self.assertEquals(len(pdata1[name]), nPoints1)              self.assertEquals(len(pdata1[name]), nPoints1)
244              if not name.startswith('mesh_vars/'):              if not name.startswith('mesh_vars/'):
245                  self.assertTrue(self.compareDataWithMap(                  self.assertTrue(self.compareDataWithMap(
# Line 251  class Test_VTKSaver(unittest.TestCase): Line 251  class Test_VTKSaver(unittest.TestCase):
251          cdata2=p2.getCellData()          cdata2=p2.getCellData()
252          self.assertEquals(len(cdata1), len(cdata2))          self.assertEquals(len(cdata1), len(cdata2))
253          for name in cdata2:          for name in cdata2:
254              self.assertTrue(cdata1.has_key(name), "Cell variable '%s' missing"%name)              self.assertTrue(name in cdata1, "Cell variable '%s' missing"%name)
255              self.assertEquals(len(cdata1[name]), nCells1)              self.assertEquals(len(cdata1[name]), nCells1)
256              if not name.startswith('mesh_vars/'):              if not name.startswith('mesh_vars/'):
257                  self.assertTrue(self.compareDataWithMap(                  self.assertTrue(self.compareDataWithMap(

Legend:
Removed from v.3774  
changed lines
  Added in v.3775

  ViewVC Help
Powered by ViewVC 1.1.26