Skip to content
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

Do not allow partial matches when updating OverlayPlot #5962

Merged
merged 3 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,6 @@ def model_changed(self, model):
return any(md['id'] == model.ref['id'] for models in stream_metadata
for md in models.values())


@property
def framewise(self):
"""
Expand Down Expand Up @@ -2989,10 +2988,8 @@ def update_frame(self, key, ranges=None, element=None):
# If not batched get the Element matching the subplot
elif element is not None:
idx, spec, exact = self._match_subplot(k, subplot, items, element)
if idx is not None:
if idx is not None and exact:
_, el = items.pop(idx)
if not exact:
self._update_subplot(subplot, spec)

# Skip updates to subplots when its streams is not one of
# the streams that initiated the update
Expand Down
20 changes: 2 additions & 18 deletions holoviews/tests/plotting/bokeh/test_overlayplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from bokeh.models import FactorRange, FixedTicker, HoverTool, Range1d, Span

from holoviews.core import DynamicMap, HoloMap, NdOverlay, Overlay
from holoviews.core.options import Cycle
from holoviews.element import (
Bars,
Box,
Expand Down Expand Up @@ -301,21 +300,6 @@ def test_overlay_legend_with_labels(self):
legend_labels = [l.label['value'] for l in plot.state.legend[0].items]
self.assertEqual(legend_labels, ['A Curve', 'B Curve'])

def test_dynamic_subplot_remapping(self):
# Checks that a plot is appropriately updated when reused
def cb(X):
return NdOverlay({i: Curve(np.arange(10)+i) for i in range(X-2, X)})
dmap = DynamicMap(cb, kdims=['X']).redim.range(X=(1, 10))
plot = bokeh_renderer.get_plot(dmap)
plot.update((3,))
legend_labels = [property_to_dict(item.label) for item in plot.state.legend[0].items]
self.assertEqual(legend_labels, [{'value': '1'}, {'value': '2'}])
colors = Cycle().values
for i, (subplot, color) in enumerate(zip(plot.subplots.values(), colors[3:])):
self.assertEqual(subplot.handles['glyph'].line_color, color)
self.assertEqual(subplot.cyclic_index, i+3)
self.assertEqual(list(subplot.overlay_dims.values()), [i+1])

def test_holomap_legend_updates(self):
hmap = HoloMap({i: Curve([1, 2, 3], label=chr(65+i+2)) * Curve([1, 2, 3], label='B')
for i in range(3)})
Expand Down Expand Up @@ -350,10 +334,10 @@ def test_dynamicmap_legend_updates(self):
self.assertEqual(legend_labels, [{'value': 'C'}, {'value': 'B'}])
plot.update((1,))
legend_labels = [property_to_dict(item.label) for item in plot.state.legend[0].items]
self.assertEqual(legend_labels, [{'value': 'D'}, {'value': 'B'}])
self.assertEqual(legend_labels, [{'value': 'B'}, {'value': 'D'}])
plot.update((2,))
legend_labels = [property_to_dict(item.label) for item in plot.state.legend[0].items]
self.assertEqual(legend_labels, [{'value': 'E'}, {'value': 'B'}])
self.assertEqual(legend_labels, [{'value': 'B'}, {'value': 'E'}])

def test_dynamicmap_legend_updates_add_dynamic_plots(self):
hmap = HoloMap({i: Overlay([Curve([1, 2, j], label=chr(65+j)) for j in range(i)]) for i in range(1, 4)})
Expand Down