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

Disable batching when subcoordinate_y is enabled #6272

Merged
merged 4 commits into from
Jun 10, 2024
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
4 changes: 4 additions & 0 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -3004,6 +3004,10 @@ def _y_range_type(self):
return v._y_range_type
return self._y_range_type

@property
def _is_batched(self):
return super()._is_batched and not self.subcoordinate_y

def _process_legend(self, overlay):
plot = self.handles['plot']
subplots = self.traverse(lambda x: x, [lambda x: x is not self])
Expand Down
6 changes: 5 additions & 1 deletion holoviews/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1797,10 +1797,14 @@ def _apply_compositor(self, holomap, ranges=None, keys=None, dimensions=None):
collapsed = Compositor.collapse(holomap, (ranges, frame_ranges.keys()), mode='display')
return collapsed

@property
def _is_batched(self):
return self.batched and type(self.hmap.last) is NdOverlay

def _create_subplots(self, ranges):
# Check if plot should be batched
ordering = util.layer_sort(self.hmap)
batched = self.batched and type(self.hmap.last) is NdOverlay
batched = self._is_batched
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
if batched:
backend = self.renderer.backend
batchedplot = Store.registry[backend].get(self.hmap.last.type)
Expand Down
8 changes: 7 additions & 1 deletion holoviews/tests/core/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

from holoviews import Element, NdOverlay
from holoviews import Curve, Element, NdOverlay, Overlay


class CompositeTest(unittest.TestCase):
Expand All @@ -29,6 +29,12 @@ def test_overlay_iter(self):
for el, v in zip(overlay, views):
self.assertEqual(el, v)

def test_overlay_iterable(self):
# Related to https://github.com/holoviz/holoviews/issues/5315
c1 = Curve([0, 1])
c2 = Curve([10, 20])
Overlay({'a': c1, 'b': c2}.values())

def test_overlay_integer_indexing(self):
overlay = NdOverlay(list(enumerate([self.view1, self.view2, self.view3])))
self.assertEqual(overlay[0], self.view1)
Expand Down
14 changes: 9 additions & 5 deletions holoviews/tests/plotting/bokeh/test_overlayplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,15 @@ def test(x):
_, vline_plot = plot.subplots.values()
assert vline_plot.handles['glyph'].location == 1

def test_overlay_iterable(self):
# Related to https://github.com/holoviz/holoviews/issues/5315
c1 = Curve([0, 1])
c2 = Curve([10, 20])
Overlay({'a': c1, 'b': c2}.values())
def test_ndoverlay_subcoordinate_y_no_batching(self):
overlay = NdOverlay({
i: Curve(np.arange(10)*i).opts(subcoordinate_y=True) for i in range(10)
}).opts(legend_limit=1)
plot = bokeh_renderer.get_plot(overlay)

assert plot.batched == False
assert len(plot.subplots) == 10



class TestLegends(TestBokehPlot):
Expand Down