Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Christian Butz
VTK
Commits
9b1e3510
Commit
9b1e3510
authored
Oct 14, 2016
by
Shawn Waldon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Xdmf3 tests for python3
parent
94d03e0b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
38 deletions
+41
-38
IO/Xdmf3/Testing/Python/ManyFiles.py
IO/Xdmf3/Testing/Python/ManyFiles.py
+4
-2
IO/Xdmf3/Testing/Python/ReadXdmfPolyhedron.py
IO/Xdmf3/Testing/Python/ReadXdmfPolyhedron.py
+5
-3
IO/Xdmf3/Testing/Python/VToXLoop.py
IO/Xdmf3/Testing/Python/VToXLoop.py
+32
-33
No files found.
IO/Xdmf3/Testing/Python/ManyFiles.py
View file @
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
...
...
IO/Xdmf3/Testing/Python/ReadXdmfPolyhedron.py
View file @
9b1e3510
...
...
@@ -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
()
)
IO/Xdmf3/Testing/Python/VToXLoop.py
View file @
9b1e3510
...
...
@@ -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
x
range
(
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"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment