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
8 changes: 4 additions & 4 deletions mayavi/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ def get_range(self, attr='scalars', mode='point'):
if x is None:
return None, [0.0, 1.0]
name, x = x
if self._composite:
if isinstance(x, dsa.VTKNoneArray):
res = [0.0, 1.0]
elif self._composite:
# Don't bother with Nans for composite data for now.
if isinstance(x, dsa.VTKNoneArray):
res = [0.0, 1.0]
elif attr == 'scalars':
if attr == 'scalars':
res = [algs.min(x), algs.max(x)]
else:
max_norm = np.sqrt(algs.max(algs.sum(x*x, axis=1)))
Expand Down
10 changes: 10 additions & 0 deletions mayavi/tests/test_core_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from tvtk.api import tvtk
from mayavi.core.utils import DataSetHelper
from vtk.numpy_interface import dataset_adapter as dsa


class TestDataSetHelper(unittest.TestCase):
Expand Down Expand Up @@ -72,6 +73,15 @@ def test_get_range_works_for_multiblock_datasets(self):
self.assertEqual(name, 'cv')
self.assertEqual(rng, [0.0, np.sqrt(3.0)])

def test_get_range_works_for_VTKNoneArray(self):
id_ = tvtk.ImageData(dimensions=(2, 2, 1), origin=(0, 0, 0),
spacing=(1, 1, 1))
id_.point_data.scalars = np.arange(4, dtype=float)
dsh = DataSetHelper(id_)
self.assertFalse(dsh._composite)
self.assertEqual(dsh.get_range(), (None, [0., 1.]))
# XXX there is some wackiness here, no idea why this changes!
self.assertEqual(dsh.get_range(), ('point_scalars', [0., 3.]))

if __name__ == '__main__':
unittest.main()