Skip to content
Merged
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
2 changes: 2 additions & 0 deletions mayavi/core/lut_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,8 @@ def _use_default_range_changed(self, value):
self._default_data_range_changed(self.default_data_range)

def _data_range_changed(self, value):
# should be guaranteed by callers, otherwise VTK will print an error
assert value[0] <= value[1]
Comment thread
prabhuramachandran marked this conversation as resolved.
try:
self.lut.set_range(value[0], value[1])
except TypeError:
Expand Down
9 changes: 9 additions & 0 deletions mayavi/tests/test_mlab_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import numpy as np
from numpy.testing import assert_allclose
from traits.testing.unittest_tools import UnittestTools
from traits.api import push_exception_handler

import vtk

Expand All @@ -23,6 +24,8 @@
from mayavi.core.registry import registry
from mayavi.tests.common import get_example_data

push_exception_handler(reraise_exceptions=True) # XXX should probably be elsewhere
Comment thread
prabhuramachandran marked this conversation as resolved.


################################################################################
# class `TestMlabNullEngine`
Expand Down Expand Up @@ -123,6 +126,12 @@ def test_mlab_source(self):
obj = factory(obj)
self.assertTrue(hasattr(obj, 'mlab_source'))

def test_strange_vmin_vmax(self):
tris = [[0, 1, 2]]
x, y, z = np.random.random((3, 3, 3))
mesh = mlab.pipeline.triangular_mesh_source(x, y, z, tris)
surf = mlab.pipeline.surface(mesh, vmin=100, vmax=101)

def test_add_dataset_works_with_vtk_datasets(self):
# Given
pd = vtk.vtkPolyData()
Expand Down
6 changes: 6 additions & 0 deletions mayavi/tools/modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,16 @@ def _vmin_changed(self):
= False
vmin, vmax = \
self._target.module_manager.scalar_lut_manager.data_range
# This takes care of pathological cases where vmin is changed
# before vmax is changed, but vmin is greater than data_range[1]
if self.vmin is not None:
vmin = self.vmin
if self.vmax is None:
vmax = max(vmax, vmin)
if self.vmax is not None:
vmax = self.vmax
if self.vmin is None:
vmin = min(vmin, vmax)
self._target.module_manager.scalar_lut_manager.data_range = \
(vmin, vmax)

Expand Down