Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VTK 9.3: Fix test suite failures (VTK API changes) #1290

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions mayavi/filters/threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Property, Enum
from traitsui.api import View, Group, Item
from tvtk.api import tvtk
from tvtk.common import vtk_major_version, vtk_minor_version

# Local imports
from mayavi.core.filter import Filter
Expand Down Expand Up @@ -165,13 +166,19 @@ def update_data(self):
######################################################################
def _lower_threshold_changed(self, new_value):
fil = self.threshold_filter
fil.threshold_between(new_value, self.upper_threshold)
if (vtk_major_version, vtk_minor_version) >= (9, 1):
fil.lower_threshold = new_value
else:
fil.threshold_between(new_value, self.upper_threshold)
fil.update()
self.data_changed = True

def _upper_threshold_changed(self, new_value):
fil = self.threshold_filter
fil.threshold_between(self.lower_threshold, new_value)
if (vtk_major_version, vtk_minor_version) >= (9, 1):
fil.upper_threshold = new_value
else:
fil.threshold_between(self.lower_threshold, new_value)
fil.update()
self.data_changed = True

Expand Down Expand Up @@ -270,8 +277,12 @@ def _threshold_filter_changed(self, old, new):
return
fil = new
self.configure_connection(fil, self.inputs[0].outputs[0])
fil.threshold_between(self.lower_threshold,
self.upper_threshold)
if (vtk_major_version, vtk_minor_version) >= (9, 1):
fil.lower_threshold = self.lower_threshold
fil.upper_threshold = self.upper_threshold
else:
fil.threshold_between(self.lower_threshold,
self.upper_threshold)
fil.update()
self._set_outputs([fil])

Expand Down
4 changes: 2 additions & 2 deletions mayavi/tests/test_set_active_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def check(self):
c = src.children[1]
sc = get_output(c.outputs[0]).point_data.scalars
self.assertEqual(sc.name,'temperature')
# It is an iso-contour!
self.assertEqual(sc.range[0],sc.range[1])
# It is an iso-contour! Allow rounding differences
self.assertAlmostEqual(sc.range[0], sc.range[1], places=5)
aa = c.children[0].children[0]
self.assertEqual(aa.point_scalars_name,'pressure')
sc = get_output(aa.outputs[0]).point_data.scalars
Expand Down
1 change: 1 addition & 0 deletions tvtk/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import vtk

vtk_major_version = vtk.vtkVersion.GetVTKMajorVersion()
vtk_minor_version = vtk.vtkVersion.GetVTKMinorVersion()


######################################################################
Expand Down
4 changes: 3 additions & 1 deletion tvtk/tests/test_vtk_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def test_parse(self):
res['NormalScale'] = (1., None)
res['OcclusionStrength'] = (1., float_max)
res['Roughness'] = (0.5, float_max)
if vtk_major_version >= 9 and vtk_minor_version > 0:
if (vtk_major_version, vtk_minor_version) >= (9, 1):
res['Anisotropy'] = (0.0, (0.0, 1.0))
res['AnisotropyRotation'] = (0.0, (0.0, 1.0))
res['BaseIOR'] = (1.5, (1.0, 9.999999680285692e+37))
Expand All @@ -140,6 +140,8 @@ def test_parse(self):
res['SelectionColor'] = ((1.0, 0.0, 0.0, 1.0), None)
res['SelectionLineWidth'] = (2.0, None)
res['SelectionPointSize'] = (2.0, None)
if (vtk_major_version, vtk_minor_version) >= (9, 3):
res['EdgeOpacity'] = (1.0, None)

result = list(p.get_get_set_methods().keys())
if hasattr(obj, 'GetTexture'):
Expand Down