Skip to content

Commit

Permalink
Fix BoundsX and BoundsY regression (#6099)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Feb 6, 2024
1 parent 8936f44 commit f81533a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ class BoundsXCallback(Callback):
models = ['plot']
on_events = ['selectiongeometry']

skip_events = [lambda event: event.geometry['type'] != 'quad',
skip_events = [lambda event: event.geometry['type'] != 'rect',
lambda event: not event.final]

def _process_msg(self, msg):
Expand All @@ -856,7 +856,7 @@ class BoundsYCallback(Callback):
models = ['plot']
on_events = ['selectiongeometry']

skip_events = [lambda event: event.geometry['type'] != 'quad',
skip_events = [lambda event: event.geometry['type'] != 'rect',
lambda event: not event.final]

def _process_msg(self, msg):
Expand Down
16 changes: 12 additions & 4 deletions holoviews/tests/ui/bokeh/test_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,24 @@

import holoviews as hv
from holoviews import Curve, DynamicMap, Scatter
from holoviews.streams import BoundsXY, Lasso, RangeXY
from holoviews.streams import BoundsX, BoundsXY, BoundsY, Lasso, RangeXY


@pytest.mark.usefixtures("bokeh_backend")
def test_box_select(page, port):
@pytest.mark.parametrize(
["BoundsTool", "bound_slice", "bound_attr"],
[
(BoundsXY, slice(None), "bounds"),
(BoundsX, slice(0, None, 2), "boundsx"),
(BoundsY, slice(1, None, 2), "boundsy"),
],
)
def test_box_select(page, port, BoundsTool, bound_slice, bound_attr):
hv_scatter = Scatter([1, 2, 3]).opts(
tools=['box_select'], active_tools=['box_select']
)

bounds = BoundsXY(source=hv_scatter)
bounds = BoundsTool(source=hv_scatter)

pn_scatter = HoloViews(hv_scatter)

Expand All @@ -45,7 +53,7 @@ def test_box_select(page, port):
page.mouse.up()

expected_bounds = (0.32844036697247725, 1.8285714285714285, 0.8788990825688077, 2.3183673469387758)
wait_until(lambda: bounds.bounds == expected_bounds, page)
wait_until(lambda: getattr(bounds, bound_attr) == expected_bounds[bound_slice], page)


@pytest.mark.usefixtures("bokeh_backend")
Expand Down

0 comments on commit f81533a

Please sign in to comment.