-
-
Notifications
You must be signed in to change notification settings - Fork 407
fix: setting selection_expr
programmatically
#6689
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,7 +116,7 @@ | |
self.assertEqual(region, Rectangles([])) | ||
|
||
def test_points_selection_hide_region(self): | ||
self.test_points_selection(show_regions=False) | ||
Check failure on line 119 in holoviews/tests/test_selection.py
|
||
|
||
def test_points_selection_dynamic(self): | ||
self.test_points_selection(dynamic=True) | ||
|
@@ -175,6 +175,18 @@ | |
] | ||
) | ||
|
||
def test_select_expr_show_regions(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need a UI test for this change. |
||
lnk_sel = link_selections.instance() | ||
self.assertTrue(lnk_sel.show_regions) | ||
se = ( | ||
(hv.dim('x') >= 0) & (hv.dim('x') <= 1) & | ||
(hv.dim('y') >= 0) & (hv.dim('y') <= 1) | ||
) | ||
lnk_sel.selection_expr = se | ||
self.assertTrue(lnk_sel.show_regions) | ||
Check failure on line 186 in holoviews/tests/test_selection.py
|
||
lnk_sel.selection_expr = None | ||
self.assertTrue(lnk_sel.show_regions) | ||
|
||
def test_overlay_points_errorbars(self, dynamic=False): | ||
points = Points(self.data) | ||
error = ErrorBars(self.data, kdims='x', vdims=['y', 'e']) | ||
|
@@ -637,7 +649,7 @@ | |
self.test_points_histogram_overwrite_intersect(dynamic=True) | ||
|
||
def test_points_histogram_overwrite_intersect_hide_region(self, dynamic=False): | ||
self.do_crossfilter_points_histogram( | ||
Check failure on line 652 in holoviews/tests/test_selection.py
|
||
selection_mode="overwrite", cross_filter_mode="intersect", | ||
selected1=[1, 2], selected2=[1], selected3=[0], selected4=[2], | ||
points_region1=[], | ||
|
@@ -649,7 +661,7 @@ | |
) | ||
|
||
def test_points_histogram_overwrite_intersect_hide_region_dynamic(self): | ||
self.test_points_histogram_overwrite_intersect_hide_region(dynamic=True) | ||
Check failure on line 664 in holoviews/tests/test_selection.py
|
||
|
||
def test_points_histogram_intersect_intersect(self, dynamic=False): | ||
self.do_crossfilter_points_histogram( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
import pytest | ||
|
||
import holoviews as hv | ||
from holoviews.plotting.bokeh.renderer import BokehRenderer | ||
from holoviews.selection import link_selections | ||
|
||
from .. import expect | ||
|
||
pytestmark = pytest.mark.ui | ||
|
||
|
||
@pytest.mark.usefixtures("bokeh_backend") | ||
def test_link_selections_programmatic_clear_removes_region(serve_hv): | ||
points = hv.Points([1, 2, 3, 4, 5, 6, 7, 8]).opts(width=400, height=300) | ||
|
||
# Helper to inspect bokeh model renderers for region-like glyphs | ||
def count_highlighted_region_renderers(bokeh_plot): | ||
cnt = 0 | ||
for r in bokeh_plot.renderers: | ||
data = r.data_source.data | ||
if len(data.get("left", [])) > 0: | ||
cnt += 1 | ||
continue | ||
return cnt | ||
|
||
ls = link_selections.instance() | ||
linked = ls(points).opts(active_tools=["box_select"]) | ||
|
||
page = serve_hv(linked) | ||
hv_plot = page.locator(".bk-events") | ||
expect(hv_plot).to_have_count(1) | ||
bbox = hv_plot.bounding_box() | ||
|
||
page.wait_for_timeout(300) | ||
initial_count = count_highlighted_region_renderers(BokehRenderer.get_plot(linked[()]).state) | ||
assert initial_count == 0 | ||
|
||
# Box-drag selection | ||
start_x = bbox["x"] + bbox["width"] * 0.25 | ||
start_y = bbox["y"] + bbox["height"] * 0.25 | ||
end_x = bbox["x"] + bbox["width"] * 0.75 | ||
end_y = bbox["y"] + bbox["height"] * 0.75 | ||
|
||
hv_plot.click() | ||
page.mouse.move(start_x, start_y) | ||
page.mouse.down(button="left") | ||
page.mouse.move(end_x, end_y, steps=10) | ||
page.mouse.up(button="left") | ||
|
||
page.wait_for_timeout(200) | ||
|
||
assert ls.selection_expr is not None | ||
|
||
# Ensure at least one new region renderer was created by the interaction | ||
post_select_count = count_highlighted_region_renderers(BokehRenderer.get_plot(linked[()]).state) | ||
assert post_select_count == initial_count + 1 | ||
|
||
ls.selection_expr = None | ||
page.wait_for_timeout(200) | ||
|
||
# Final region count should be back to initial | ||
final_count = count_highlighted_region_renderers(BokehRenderer.get_plot(linked[()]).state) | ||
assert final_count == initial_count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what fixes #6688