Fix an IndexError in .../figure_factory/_trisurf.py::map_face2color
The function map_face2color in _trisurf.py compared face value (face) to max face value (vmax) and if equal did a quick exit by returning the last element in a list. Later it would compare normalized face value to indexed values. Because of floating point errors the normalized value could be 1.0 and lead to attempted look up at an index past the end of a list. This would raise an IndexError.
The essence of the problem is
def map_face2color(face, colormap, scale, vmin, vmax):
if face == vmax: return colormap[-1];
t = (face - vmin) / (vmax - vmin) # normalized position
# t can be equal to 1.0 even when face != vmax.
# when t is equal to 1.0 finding first element past t in a list fails with IndexError
Code PR
- [x] I have read through the contributing notes and understand the structure of the package. In particular, if my PR modifies code of
plotly.graph_objects, my modifications concern thecodegenfiles and not generated files. - [x] I have added tests (if submitting a new feature or correcting a bug) or modified existing tests.
- [ ] For a new feature, I have added documentation examples in an existing or new tutorial notebook (please see the doc checklist as well).
- [ ] I have added a CHANGELOG entry if fixing/changing/adding anything substantial.
- [ ] For a new feature or a change in behaviour, I have updated the relevant docstrings in the code to describe the feature or behaviour (please see the doc checklist as well).
Would this be more interesting to merge if the content was reorganized? If so, how?
This solves issue #3323
https://guides.github.com/features/mastering-markdown/
@wilhelm-now thank you again for submitting this - I'm very sorry it's taken us so long to get to it, but we are no longer enhancing figure factory, so I'm going to close this one as stale. Best regards - @gvwilson