From 14869550861111538584840503f237113a403726 Mon Sep 17 00:00:00 2001 From: maximlt Date: Mon, 11 Sep 2023 13:48:48 +0200 Subject: [PATCH] add test with Image as a source --- holoviews/core/overlay.py | 2 +- holoviews/tests/plotting/bokeh/test_links.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/holoviews/core/overlay.py b/holoviews/core/overlay.py index ccd3e14a3c..39eebb244e 100644 --- a/holoviews/core/overlay.py +++ b/holoviews/core/overlay.py @@ -289,7 +289,7 @@ def shape(self): def clone(self, data=None, shared_data=True, new_type=None, link=True, *args, **overrides): - if link: + if data is None and link: overrides['plot_id'] = self._plot_id return super().clone(data, shared_data=shared_data, new_type=new_type, link=link, *args, **overrides) diff --git a/holoviews/tests/plotting/bokeh/test_links.py b/holoviews/tests/plotting/bokeh/test_links.py index 766e25ecdc..78fdb9f3cb 100644 --- a/holoviews/tests/plotting/bokeh/test_links.py +++ b/holoviews/tests/plotting/bokeh/test_links.py @@ -2,7 +2,7 @@ import pytest from holoviews.core.spaces import DynamicMap -from holoviews.element import Curve, Polygons, Table, Scatter, Path, Points +from holoviews.element import Curve, Image, Polygons, Table, Scatter, Path, Points from holoviews.plotting.links import (Link, RangeToolLink, DataLink) from bokeh.models import ColumnDataSource @@ -40,6 +40,20 @@ def test_range_tool_link_callback_single_axis_overlay_target(self): self.assertEqual(range_tool.x_range, tgt_plot.handles['x_range']) self.assertIs(range_tool.y_range, None) + def test_range_tool_link_callback_single_axis_overlay_target_image_source(self): + from bokeh.models import RangeTool + data = np.random.rand(50, 50) + target = Curve(data) * Curve(data) + source = Image(np.random.rand(50, 50), bounds=(0, 0, 1, 1)) + RangeToolLink(source, target) + layout = target + source + plot = bokeh_renderer.get_plot(layout) + tgt_plot = plot.subplots[(0, 0)].subplots['main'] + src_plot = plot.subplots[(0, 1)].subplots['main'] + range_tool = src_plot.state.select_one({'type': RangeTool}) + self.assertEqual(range_tool.x_range, tgt_plot.handles['x_range']) + self.assertIs(range_tool.y_range, None) + def test_range_tool_link_callback_both_axes(self): from bokeh.models import RangeTool array = np.random.rand(100, 2)