Commit e95e780f authored by David E. DeMarle's avatar David E. DeMarle

Merge commit '9b1e3510' into release

parents 2af6d5aa 9b1e3510
......@@ -3,6 +3,8 @@ This test verifies that vtk's Xdmf reader will read a sampling of small
to moderate size data files that cover a spectrum of file format features.
"""
from __future__ import print_function
import sys
import vtk
from vtk.util.misc import vtkGetDataRoot
......@@ -58,14 +60,14 @@ if __name__ == "__main__":
for fname in testfilenames:
xr = vtk.vtkXdmf3Reader()
afname = "" + str(VTK_DATA_ROOT) + "/Data/XDMF/" + fname
print "Trying ", afname
print ("Trying %s" % afname)
xr.CanReadFile(afname)
xr.SetFileName(afname)
xr.UpdateInformation()
xr.Update()
ds = xr.GetOutputDataObject(0)
if not ds:
print "Got zero output from known good file"
print("Got zero output from known good file")
sys.exit(vtk.VTK_ERROR)
#if res != vtk.VTK_OK:
# print "Could not read", afname
......
......@@ -2,6 +2,8 @@
This test verifies that vtk's Xdmf reader will read a polyhedron sample file.
"""
from __future__ import print_function
import os, sys
import vtk
from vtk.util.misc import vtkGetDataRoot
......@@ -17,8 +19,8 @@ if __name__ == "__main__":
xr.Update()
ds = xr.GetOutputDataObject(0)
if not ds:
print "Got zero output from known good file"
print("Got zero output from known good file")
sys.exit(vtk.VTK_ERROR)
print ds.GetCells()
print ds.GetPoints()
print(ds.GetCells())
print(ds.GetPoints())
......@@ -5,6 +5,9 @@ to and reading it from an xdmf file and compares the read in
generated result with the read in result and passes if each
closely matches.
"""
from __future__ import print_function
import os
import sys
import vtk
......@@ -60,7 +63,7 @@ def MemUsage(point):
return '''%s:[cpu stats unavailable]'''%point
def raiseErrorAndExit(message):
raise Exception, message
raise Exception(message)
sys.exit(vtk.VTK_ERROR)
def DoFilesExist(xdmfFile, hdf5File, vtkFile, deleteIfSo):
......@@ -150,8 +153,8 @@ def DoDataObjectsDiffer(dobj1, dobj2):
(bds1[4]!=bds2[4]) or\
(bds1[5]!=bds2[5]):
for x in range(0,6):
print bds1[x], " ", bds2[x], ",",
print
print("%f %f," % (bds1[x], bds2[x]))
print()
raiseErrorAndExit("Bounds test failed")
if (ds1.GetPointData().GetNumberOfArrays() !=\
......@@ -205,8 +208,7 @@ def TestXdmfConversion(dataInput, fileName):
timer.StartTimer()
xWriter.Write()
timer.StopTimer()
print "vtkXdmf3Writer took", timer.GetElapsedTime(), "seconds to write",\
xdmfFile
print("vtkXdmf3Writer took %f seconds to write %s" % (timer.GetElapsedTime(), xdmfFile))
ds = vtk.vtkDataSet.SafeDownCast(dataInput)
if ds:
......@@ -224,8 +226,7 @@ def TestXdmfConversion(dataInput, fileName):
timer.StartTimer()
xReader.Update()
timer.StopTimer()
print "vtkXdmf3Reader took", timer.GetElapsedTime(), "seconds to read",\
xdmfFile
print("vtkXdmf3Reader took %f seconds to read %s" % (timer.GetElapsedTime(), xdmfFile))
rOutput = xReader.GetOutputDataObject(0)
......@@ -242,21 +243,21 @@ def TestXdmfConversion(dataInput, fileName):
def RunTest():
fail = False
print "TEST SET 1 - verify reader/writer work for range of canonical datasets"
print MemUsage("Before starting TEST SET 1")
print("TEST SET 1 - verify reader/writer work for range of canonical datasets")
print(MemUsage("Before starting TEST SET 1"))
dog = vtk.vtkDataObjectGenerator()
i = 0
for testObject in testObjects:
fileName = "xdmfIOtest_" + str(i)
print "Test vtk object", testObject
print("Test vtk object {}".format(testObject))
dog.SetProgram(testObject)
dog.Update()
TestXdmfConversion(dog.GetOutput(), fileName)
i += 1
print "TEST SET 2 - verify reader/writer work for Graphs"
print MemUsage("Before starting TEST SET 2")
print "Test Graph data"
print("TEST SET 2 - verify reader/writer work for Graphs")
print(MemUsage("Before starting TEST SET 2"))
print("Test Graph data")
gsrc = vtk.vtkRandomGraphSource()
gsrc.DirectedOn()
gsrc.Update()
......@@ -270,8 +271,7 @@ def RunTest():
timer.StartTimer()
xWriter.Write()
timer.StopTimer()
print "vtkXdmf3Writer took", timer.GetElapsedTime(), "seconds to write",\
gFileName
print("vtkXdmf3Writer took %f seconds to write %s" % (timer.GetElapsedTime(), gFileName))
xReader = vtk.vtkXdmf3Reader()
xReader.SetFileName(gFileName)
xReader.Update()
......@@ -282,9 +282,9 @@ def RunTest():
if not DoFilesExist(gFileName, ghFileName, None, CleanUpGood):
raiseErrorAndExit("Failed to write Graph file")
print "TEST SET 3 - verify reader/writer handle time varying data"
print MemUsage("Before starting TEST SET 3")
print "Test temporal data"
print("TEST SET 3 - verify reader/writer handle time varying data")
print(MemUsage("Before starting TEST SET 3"))
print("Test temporal data")
tsrc = vtk.vtkTimeSourceExample()
tsrc.GrowingOn()
tsrc.SetXAmplitude(2.0)
......@@ -299,8 +299,7 @@ def RunTest():
timer.StartTimer()
xWriter.Write()
timer.StopTimer()
print "vtkXdmf3Writer took", timer.GetElapsedTime(), "seconds to write",\
tFileName
print("vtkXdmf3Writer took %f seconds to write %s" % (timer.GetElapsedTime(), tFileName))
xReader = vtk.vtkXdmf3Reader()
xReader.SetFileName(tFileName)
xReader.UpdateInformation()
......@@ -311,33 +310,33 @@ def RunTest():
#compare number of and values for temporal range
if len(timerange) != len(correcttimes):
print "timesteps failed"
print timerange, "!=", correcttimes
print("timesteps failed")
print("{} != {}".format(timerange, correcttimes))
raiseErrorAndExit("Failed to get same times")
for i in xrange(0, len(correcttimes)):
for i in range(0, len(correcttimes)):
if abs(abs(timerange[i])-abs(correcttimes[i])) > 0.000001:
print "time result failed"
print timerange, "!=", correcttimes
print("time result failed")
print("{} != {}".format(timerange, correcttimes))
raiseErrorAndExit("Failed to get same times")
#exercise temporal processing and compare geometric bounds at each tstep
indices = range(0,len(timerange)) + range(len(timerange)-2,-1,-1)
indices = [x for x in range(0,len(timerange))] + [x for x in range(len(timerange)-2,-1,-1)]
for x in indices:
xReader.UpdateTimeStep(timerange[x])
obds = xReader.GetOutputDataObject(0).GetBounds()
tsrc.UpdateTimeStep(timerange[x]+0.0001) #workaround a precision bug in TSE
ibds = tsrc.GetOutputDataObject(0).GetBounds()
print timerange[x], obds
print("{} {}".format( timerange[x], obds))
for i in (0,1,2,3,4,5):
if abs(abs(obds[i])-abs(ibds[i])) > 0.000001:
print "time result failed"
print obds, "!=", ibds
print("time result failed")
print("{} != {}".format(obds, ibds))
raiseErrorAndExit("Failed to get same data for this timestep")
fail = DoFilesExist(tFileName, thFileName, None, CleanUpGood)
if not fail:
raiseErrorAndExit("Failed Temporal Test")
print MemUsage("End of Testing")
print(MemUsage("End of Testing"))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Test Xdmf3 IO")
......@@ -352,10 +351,10 @@ if __name__ == "__main__":
if args.outputDir:
OutputDir = args.outputDir[0] + "/"
print "Test XML Arrays"
print("Test XML Arrays")
LightDataLimit = 10000
RunTest()
print "Test HDF5 Arrays"
print("Test HDF5 Arrays")
LightDataLimit = 0
RunTest()
print "That's all folks"
print("That's all folks")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment