Skip to content

Commit 0263f77

Browse files
dgobbikwrobot
authored andcommittedJan 18, 2023
Merge topic 'remove-vtkTclTest2Py'
d94e3b9 Remove the Utilities/vtkTclTest2Py directory de09db1 Move rtImageTest.py to vtkmodules.test.rtImageTest b92dac0 Remove some Tcl-isms from Python tests Acked-by: Kitware Robot <[email protected]> Acked-by: buildbot <[email protected]> Reviewed-by: Ben Boeckel <[email protected]> Merge-request: !9847
2 parents 1949efd + d94e3b9 commit 0263f77

28 files changed

+208
-1240
lines changed
 

‎CMake/vtkModuleTesting.cmake

+4-14
Original file line numberDiff line numberDiff line change
@@ -590,18 +590,11 @@ Options:
590590
providing a baseline dir, assuming `NO_VALID` is not specified.
591591
- `DIRECT_DATA` : If `DIRECT_DATA` is specified, the baseline path will be provided
592592
as is, without the use of ExternalData_add_test.
593-
- `JUST_VALID`: Only applies when both `NO_VALID` and `NO_RT` are not
594-
present. If it is not specified, `-A` is passed with path to the directory
595-
of the `vtkTclTest2Py` Python package and the test is run via the
596-
`rtImageTest.py` script. Note that this currently only works when building
597-
against a VTK build tree; the VTK install tree does not include this script
598-
or its associated Python package.
593+
- `JUST_VALID`: Only applies when neither `NO_VALID` or `NO_RT` are present.
594+
If it is not specified, the test is run via `vtkmodules.test.rtImageTest`.
599595
600596
Additional flags may be passed to tests using the `${_vtk_build_test}_ARGS`
601597
variable or the `<NAME>_ARGS` variable.
602-
603-
Note that the `vtkTclTest2Py` support will eventually be removed. It is a
604-
legacy of the conversion of many tests from Tcl to Python.
605598
#]==]
606599
function (vtk_add_test_python)
607600
if (NOT _vtk_testing_python_exe)
@@ -637,7 +630,6 @@ function (vtk_add_test_python)
637630
set(rtImageTest "")
638631
set(_B "")
639632
set(_V "")
640-
set(_A "")
641633
if (NOT local_NO_VALID)
642634
if (local_NO_RT)
643635
if (local_DIRECT_DATA)
@@ -652,9 +644,7 @@ function (vtk_add_test_python)
652644
set(_V -V "DATA{${CMAKE_CURRENT_SOURCE_DIR}/../Data/Baseline/${test_name}.png,:}")
653645
endif()
654646
if (NOT local_JUST_VALID)
655-
# TODO: This should be fixed to also work from an installed VTK.
656-
set(rtImageTest "${VTK_SOURCE_DIR}/Utilities/vtkTclTest2Py/rtImageTest.py")
657-
set(_A -A "${VTK_SOURCE_DIR}/Utilities/vtkTclTest2Py")
647+
set(rtImageTest -m "vtkmodules.test.rtImageTest")
658648
endif ()
659649
endif ()
660650
endif ()
@@ -689,7 +679,7 @@ function (vtk_add_test_python)
689679
${args}
690680
${${_vtk_build_test}_ARGS}
691681
${${test_name}_ARGS}
692-
${_D} ${_B} ${_T} ${_V} ${_A})
682+
${_D} ${_B} ${_T} ${_V})
693683

694684
if (local_DIRECT_DATA)
695685
add_test(${testArgs})

‎CMakeLists.txt

-7
Original file line numberDiff line numberDiff line change
@@ -630,13 +630,6 @@ if (VTK_BUILD_DOCUMENTATION)
630630
add_subdirectory(Utilities/Doxygen)
631631
endif ()
632632

633-
# If python wrapping and testing is enabled then add driver scripts to run
634-
# tests. Note: Many python tests used to be automatically converted from TCL
635-
# scripts. Hence the name vtkTclTest2Py
636-
if (VTK_BUILD_TESTING AND VTK_WRAP_PYTHON)
637-
add_subdirectory(Utilities/vtkTclTest2Py)
638-
endif ()
639-
640633
if (NOT TARGET uninstall)
641634
add_custom_target(uninstall
642635
COMMAND

‎Filters/Parallel/Testing/Python/RectOutline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
outlineMapper.SetPiece(1)
2525
outlineActor = vtkActor()
2626
outlineActor.SetMapper(outlineMapper)
27-
outlineActor.GetProperty().SetColor(black)
27+
outlineActor.GetProperty().SetColor(0.0, 0.0, 0.0)
2828
# Graphics stuff
2929
# Create the RenderWindow, Renderer and both Actors
3030
#

‎Filters/Parallel/Testing/Python/TestCutMaterial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
cam = ren.GetActiveCamera()
6969
cam.SetFocalPoint(p)
7070
cam.SetViewUp(cut.GetUpVector())
71-
cam.SetPosition(expr.expr(globals(), locals(),["lindex(n,0)","+","lindex(p,0)"]),expr.expr(globals(), locals(),["lindex(n,1)","+","lindex(p,1)"]),expr.expr(globals(), locals(),["lindex(n,2)","+","lindex(p,2)"]))
71+
cam.SetPosition(n[0] + p[0], n[1] + p[1], n[2] + p[2])
7272
ren.ResetCamera()
7373
iren = vtkRenderWindowInteractor()
7474
iren.SetRenderWindow(renWin)

‎Filters/Parallel/Testing/Python/TestImageStreamer.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
from vtkmodules.vtkIOImage import vtkImageReader
55
from vtkmodules.vtkImagingCore import vtkImageMapToColors
66
from vtkmodules.vtkInteractionImage import vtkImageViewer
7+
import vtkmodules.vtkRenderingFreeType
8+
import vtkmodules.vtkRenderingOpenGL2
79

810
reader = vtkImageReader()
911
reader.ReleaseDataFlagOff()
@@ -22,14 +24,13 @@
2224
LUT.Build()
2325
# added these unused default arguments so that the prototype
2426
# matches as required in python.
25-
def changeLUT (a=0,b=0,__vtk__temp0=0,__vtk__temp1=0):
27+
def changeLUT(*args):
2628
global rangeStart, rangeEnd
27-
rangeStart = expr.expr(globals(), locals(),["rangeStart","+","0.1"])
28-
rangeEnd = expr.expr(globals(), locals(),["rangeEnd","+","0.1"])
29-
if (rangeEnd > 1.0):
29+
rangeStart += 0.1
30+
rangeEnd += 0.1
31+
if rangeEnd > 1.0:
3032
rangeStart = 0.0
3133
rangeEnd = 0.2
32-
pass
3334
LUT.SetHueRange(rangeStart,rangeEnd)
3435
LUT.Build()
3536

‎Filters/Programmable/Testing/Python/MultidimensionalSolution.py

+11-24
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import vtkmodules.vtkRenderingFreeType
2121
import vtkmodules.vtkRenderingOpenGL2
2222
from vtkmodules.util.misc import vtkGetDataRoot
23+
import math
24+
2325
VTK_DATA_ROOT = vtkGetDataRoot()
2426

2527
#
@@ -83,42 +85,27 @@
8385
pressureGradient = vtkHedgeHog()
8486
pressureGradient.SetInputConnection(probe_gradient.GetOutputPort())
8587
pressureGradient.SetScaleFactor(0.00002)
86-
def ExecuteDot (__vtk__temp0=0,__vtk__temp1=0):
87-
# proc for ProgrammableAttributeDataFilter. Note the use of "double()"
88-
# in the calculations. This protects us from Python using ints and
89-
# overflowing.
88+
def ExecuteDot():
89+
# proc for ProgrammableAttributeDataFilter.
9090
inputs = dotProduct.GetInputList()
9191
input0 = inputs.GetDataSet(0)
9292
input1 = inputs.GetDataSet(1)
9393
numPts = input0.GetNumberOfPoints()
9494
vectors0 = input0.GetPointData().GetVectors()
9595
vectors1 = input1.GetPointData().GetVectors()
9696
scalars = vtkFloatArray()
97-
i = 0
98-
while i < numPts:
99-
v0 = vectors0.GetTuple3(i)
100-
v1 = vectors1.GetTuple3(i)
101-
v0x = lindex(v0,0)
102-
v0y = lindex(v0,1)
103-
v0z = lindex(v0,2)
104-
v1x = lindex(v1,0)
105-
v1y = lindex(v1,1)
106-
v1z = lindex(v1,2)
107-
l0 = expr.expr(globals(), locals(),["double","(","v0x",")*","double","(","v0x",")","+","double","(","v0y",")*","double","(","v0y",")","+","double","(","v0z",")*","double","(","v0z",")"])
108-
l1 = expr.expr(globals(), locals(),["double","(","v1x",")*","double","(","v1x",")","+","double","(","v1y",")*","double","(","v1y",")","+","double","(","v1z",")*","double","(","v1z",")"])
109-
l0 = expr.expr(globals(), locals(),["sqrt","(","double","(","l0","))"])
110-
l1 = expr.expr(globals(), locals(),["sqrt","(","double","(","l1","))"])
111-
if (l0 > 0.0 and l1 > 0.0):
112-
d = expr.expr(globals(), locals(),["(","double","(","v0x",")*","double","(","v1x",")","+","double","(","v0y",")*","double","(","v1y",")","+","double","(","v0z",")*","double","(","v1z","))/(","l0","*","l1",")"])
113-
pass
97+
for i in range(numPts):
98+
v0x,v0y,v0z = vectors0.GetTuple3(i)
99+
v1x,v1y,v1z = vectors1.GetTuple3(i)
100+
l0 = math.sqrt(v0x*v0x + v0y*v0y + v0z*v0z)
101+
l1 = math.sqrt(v1x*v1x + v1y*v1y + v1z*v1z)
102+
if l0 > 0.0 and l1 > 0.0:
103+
d = (v0x*v1x + v0y*v1y + v0z*v1z)/(l0*l1)
114104
else:
115105
d = 0.0
116-
pass
117106
scalars.InsertValue(i,d)
118-
i = i + 1
119107

120108
dotProduct.GetOutput().GetPointData().SetScalars(scalars)
121-
del scalars
122109

123110
#
124111
# We use the ProgrammableAttributeDataFilter to compute the cosine

‎Filters/Programmable/Testing/Python/progGlyphs.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,16 @@
3131
planeActor.SetMapper(planeMapper)
3232
planeActor.GetProperty().SetRepresentationToWireframe()
3333
# procedure for generating glyphs
34-
def Glyph (__vtk__temp0=0,__vtk__temp1=0):
35-
global res
34+
def Glyph():
3635
ptId = glypher.GetPointId()
3736
pd = glypher.GetPointData()
38-
xyz = glypher.GetPoint()
39-
x = lindex(xyz,0)
40-
y = lindex(xyz,1)
37+
x,y,z = glypher.GetPoint()
4138
length = glypher.GetInput(0).GetLength()
42-
scale = expr.expr(globals(), locals(),["length","/","(","2.0","*","res",")"])
39+
scale = length/(2.0*res)
4340
squad.SetScale(scale,scale,scale)
44-
squad.SetCenter(xyz)
45-
squad.SetPhiRoundness(expr.expr(globals(), locals(),["abs","(","x",")*","5.0"]))
46-
squad.SetThetaRoundness(expr.expr(globals(), locals(),["abs","(","y",")*","5.0"]))
41+
squad.SetCenter(x,y,z)
42+
squad.SetPhiRoundness(abs(x)*5.0)
43+
squad.SetThetaRoundness(abs(y)*5.0)
4744
squad.Update()
4845

4946
# create simple poly data so we can apply glyph

‎Filters/Programmable/Testing/Python/progGlyphsBySource.py

+8-13
Original file line numberDiff line numberDiff line change
@@ -47,28 +47,23 @@
4747
transformSquad.SetTransform(squadTransform)
4848
transformSquad.Update()
4949
# procedure for generating glyphs
50-
def Glyph (__vtk__temp0=0,__vtk__temp1=0):
51-
global res
50+
def Glyph():
5251
ptId = glypher.GetPointId()
5352
pd = glypher.GetPointData()
54-
xyz = glypher.GetPoint()
55-
x = lindex(xyz,0)
56-
y = lindex(xyz,1)
53+
x,y,z = glypher.GetPoint()
5754
length = glypher.GetInput(0).GetLength()
58-
scale = expr.expr(globals(), locals(),["length","/","(","2.0","*","res",")"])
55+
scale = length/(2.0*res)
5956
squadTransform.Identity()
60-
if (x == y):
57+
if x == y:
6158
squad.ToroidalOn()
62-
squadTransform.Translate(xyz)
59+
squadTransform.Translate(x,y,z)
6360
squadTransform.RotateX(90)
64-
pass
6561
else:
66-
squadTransform.Translate(xyz)
62+
squadTransform.Translate(x,y,z)
6763
squad.ToroidalOff()
68-
pass
6964
squadTransform.Scale(scale,scale,scale)
70-
squad.SetPhiRoundness(expr.expr(globals(), locals(),["abs","(","x",")*","5.0"]))
71-
squad.SetThetaRoundness(expr.expr(globals(), locals(),["abs","(","y",")*","5.0"]))
65+
squad.SetPhiRoundness(abs(x)*5.0)
66+
squad.SetThetaRoundness(abs(y)*5.0)
7267

7368
glypher = vtkProgrammableGlyphFilter()
7469
glypher.SetInputConnection(colors.GetOutputPort())

‎IO/Geometry/Testing/Python/TestPolygonWriters.py

+22-25
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@
2828
import vtkmodules.vtkRenderingFreeType
2929
import vtkmodules.vtkRenderingOpenGL2
3030
from vtkmodules.util.misc import vtkGetDataRoot
31+
import os
32+
3133
VTK_DATA_ROOT = vtkGetDataRoot()
3234

35+
# seems should always be true
36+
has_vtkIVWriter = True
37+
3338
# Create the RenderWindow, Renderer and both Actors
3439
#
3540
ren1 = vtkRenderer()
@@ -72,80 +77,72 @@
7277
#
7378
# If the current directory is writable, then test the witers
7479
#
75-
if (catch.catch(globals(),"""channel = open("test.tmp", "w")""") == 0):
76-
channel.close()
77-
file.delete("-force", "test.tmp")
78-
#
79-
#
80+
if os.access(".", os.W_OK):
8081
# test the writers
8182
dsw = vtkDataSetWriter()
8283
dsw.SetInputConnection(smooth.GetOutputPort())
8384
dsw.SetFileName("brain.dsw")
8485
dsw.Write()
85-
file.delete("-force", "brain.dsw")
86+
os.remove("brain.dsw")
8687
pdw = vtkPolyDataWriter()
8788
pdw.SetInputConnection(smooth.GetOutputPort())
8889
pdw.SetFileName("brain.pdw")
8990
pdw.Write()
90-
file.delete("-force", "brain.pdw")
91-
if (info.command(globals(), locals(), "vtkIVWriter") != ""):
91+
os.remove("brain.pdw")
92+
if has_vtkIVWriter:
9293
iv = vtkIVWriter()
9394
iv.SetInputConnection(smooth.GetOutputPort())
9495
iv.SetFileName("brain.iv")
9596
iv.Write()
96-
file.delete("-force", "brain.iv")
97-
pass
97+
os.remove("brain.iv")
9898
#
9999
# the next writers only handle triangles
100100
triangles = vtkTriangleFilter()
101101
triangles.SetInputConnection(smooth.GetOutputPort())
102-
if (info.command(globals(), locals(), "vtkIVWriter") != ""):
102+
if has_vtkIVWriter:
103103
iv2 = vtkIVWriter()
104104
iv2.SetInputConnection(triangles.GetOutputPort())
105105
iv2.SetFileName("brain2.iv")
106106
iv2.Write()
107-
file.delete("-force", "brain2.iv")
108-
pass
109-
if (info.command(globals(), locals(), "vtkIVWriter") != ""):
107+
os.remove("brain2.iv")
108+
if has_vtkIVWriter:
110109
edges = vtkExtractEdges()
111110
edges.SetInputConnection(triangles.GetOutputPort())
112111
iv3 = vtkIVWriter()
113112
iv3.SetInputConnection(edges.GetOutputPort())
114113
iv3.SetFileName("brain3.iv")
115114
iv3.Write()
116-
file.delete("-force", "brain3.iv")
117-
pass
115+
os.remove("brain3.iv")
118116
byu = vtkBYUWriter()
119117
byu.SetGeometryFileName("brain.g")
120118
byu.SetScalarFileName("brain.s")
121119
byu.SetDisplacementFileName("brain.d")
122120
byu.SetInputConnection(triangles.GetOutputPort())
123121
byu.Write()
124-
file.delete("-force", "brain.g")
125-
file.delete("-force", "brain.s")
126-
file.delete("-force", "brain.d")
122+
os.remove("brain.g")
123+
os.remove("brain.s")
124+
os.remove("brain.d")
127125
mcubes = vtkMCubesWriter()
128126
mcubes.SetInputConnection(triangles.GetOutputPort())
129127
mcubes.SetFileName("brain.tri")
130128
mcubes.SetLimitsFileName("brain.lim")
131129
mcubes.Write()
132-
file.delete("-force", "brain.lim")
133-
file.delete("-force", "brain.tri")
130+
os.remove("brain.lim")
131+
os.remove("brain.tri")
134132
stl = vtkSTLWriter()
135133
stl.SetInputConnection(triangles.GetOutputPort())
136134
stl.SetFileName("brain.stl")
137135
stl.Write()
138-
file.delete("-force", "brain.stl")
136+
os.remove("brain.stl")
139137
stlBinary = vtkSTLWriter()
140138
stlBinary.SetInputConnection(triangles.GetOutputPort())
141139
stlBinary.SetFileName("brainBinary.stl")
142140
stlBinary.SetFileType(2)
143141
stlBinary.Write()
144-
file.delete("-force", "brainBinary.stl")
142+
os.remove("brainBinary.stl")
145143
cgm = vtkCGMWriter()
146144
cgm.SetInputConnection(triangles.GetOutputPort())
147145
cgm.SetFileName("brain.cgm")
148146
cgm.Write()
149-
file.delete("-force", "brain.cgm")
150-
pass
147+
os.remove("brain.cgm")
151148
# --- end of script --

0 commit comments

Comments
 (0)