BUG: LUT / colormap setting bug
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 316
- Avg merge
- 7h 44m
- Merged PRs (30d)
- 5
Description
There is a strange discrepancy when setting a colormap:
```
import numpy as np
from mayavi import mlab
fig = mlab.figure(bgcolor=(1., 1., 1.))
scalars = [1, 0, 2]
cmap = np.array([(1, 0, 0, 1), (0, 0, 0, 1), (1, 1, 1, 1)])
x, y, z = [0, 1, 0], [0, 0, 1], [-1, -1, -1]
tris = [[0, 1, 2]]
surf = mlab.triangular_mesh(x, y, z, tris, scalars=scalars)
l_m = surf.module_manager.scalar_lut_manager
# Method 1: set .table directly (works)
l_m.lut.table = cmap * 255
# Method 2: load_lut_from_list: requires setting data_range
# l_m.load_lut_from_list(cmap)
# l_m.data_range = [0, 2 + np.finfo(float).eps * 2]
# Method 3: from_array: does not update (maybe some .update() required?)
# l_m.lut.table.from_array(cmap * 255.)
```
Method 1 above works and produces (And checking `l_m.data_range`, it is `[0. 2.]`):

Method 2 without setting data range produces (and checking the value of `l_m.data_range` it is again `[0. 2.]`):

However, uncommenting the line to set the upper limit to `eps` beyond 2. produces the correct output (using 2. itself does not!):

The third method does not seem to work at all, maybe because it's operating at too low a level, similar to #488. It can thus probably be ignored since there are suitable workarounds.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.