Skip to content

Commit

Permalink
Updates to pass raster tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Oct 25, 2024
1 parent 3914656 commit 8f71e46
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion holoviews/operation/datashader.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,9 @@ def _process(self, element, key=None):
if ytype == 'datetime':
agg[y.name] = agg[y.name].astype('datetime64[ns]')

if sel_fn:
agg.attrs["has_selector"] = True
if isinstance(agg, xr.Dataset) or agg.ndim == 2:
# Replacing x and y coordinates to avoid numerical precision issues
return self.p.element_type(agg, **params)
else:
params['vdims'] = list(map(str, agg.coords[agg_fn.column].data))
Expand Down
8 changes: 6 additions & 2 deletions holoviews/plotting/bokeh/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from bokeh.models import CustomJS, CustomJSHover, DatetimeAxis, HoverTool
from bokeh.models.dom import Div, Span, Styles, ValueOf

from ...core.data import XArrayInterface
from ...core.util import cartesian_product, dimension_sanitizer, isfinite
from ...element import Raster
from ..util import categorical_legend
Expand Down Expand Up @@ -65,10 +66,12 @@ def _init_tools(self, element, callbacks=None):
if isinstance(tool, HoverTool):
hover = tool
break
if hover is None:
return tools

data = element.data

if hover is None or not (XArrayInterface.applies(data) and "has_selector" in data.attrs):
return tools

coords, vars = tuple(data.coords), tuple(data.data_vars)
dims = (*coords, *vars)

Expand Down Expand Up @@ -100,6 +103,7 @@ def _init_tools(self, element, callbacks=None):
def on_change(attr, old, new):
data_sel = data.sel(**dict(zip(coords, new)), method="nearest").to_dict()
# TODO: When ValueOf support formatter remove the rounding
# https://github.com/bokeh/bokeh/issues/14123
data_coords = {dim: round(data_sel['coords'][dim]['data'], 3) for dim in coords}
data_vars = {dim: data_sel['data_vars'][dim]['data'] for dim in vars}
if self.comm: # Jupyter Notebook
Expand Down

0 comments on commit 8f71e46

Please sign in to comment.