Skip to content

Commit

Permalink
add test with Image as a source
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Sep 11, 2023
1 parent 30fdf95 commit 1486955
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion holoviews/core/overlay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 15 additions & 1 deletion holoviews/tests/plotting/bokeh/test_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1486955

Please sign in to comment.