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

Ensure float precision issues don't cause issues with bokeh Palette generation #4934

Merged
merged 1 commit into from
May 18, 2021
Merged
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
6 changes: 5 additions & 1 deletion holoviews/plotting/bokeh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import absolute_import, division, unicode_literals

import sys

import numpy as np

from bokeh.palettes import all_palettes
Expand Down Expand Up @@ -150,7 +152,9 @@

# Register bokeh.palettes with Palette and Cycle
def colormap_generator(palette):
return lambda value: palette[int(value*(len(palette)-1))]
# Epsilon ensures float precision doesn't cause issues (#4911)
epsilon = sys.float_info.epsilon*10
return lambda value: palette[int(value*(len(palette)-1)+epsilon)]

Palette.colormaps.update({name: colormap_generator(p[max(p.keys())])
for name, p in all_palettes.items()})
Expand Down