Skip to content

Commit

Permalink
Ensure Compositor does not make superfluous copies (#2194)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr authored and jlstevens committed Dec 11, 2017
1 parent acf1c6f commit 9aee63f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 3 additions & 2 deletions holoviews/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,10 @@ def map(cls, obj, mode='data', backend=None):
if overlay_compositors:
obj = obj.map(lambda obj: cls.collapse_element(obj, mode=mode, backend=backend),
[CompositeOverlay])
if element_compositors:
element_patterns = [c.pattern for c in element_compositors]
if element_compositors and obj.traverse(lambda x: x, element_patterns):
obj = obj.map(lambda obj: cls.collapse_element(obj, mode=mode, backend=backend),
[c.pattern for c in element_compositors])
element_patterns)
return obj


Expand Down
17 changes: 14 additions & 3 deletions tests/testbokehcallbacks.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from unittest import SkipTest
from nose.plugins.attrib import attr

from holoviews.element.comparison import ComparisonTestCase
from holoviews.core import NdOverlay
from holoviews.core.options import Store

from holoviews.element import Curve
from holoviews.element.comparison import ComparisonTestCase
from holoviews.streams import Selection1D

try:
from holoviews.plotting.bokeh.callbacks import Callback
from holoviews.plotting.bokeh.callbacks import Callback, Selection1DCallback
from holoviews.plotting.bokeh.util import bokeh_version

from bokeh.events import Tap
Expand Down Expand Up @@ -52,6 +54,15 @@ def test_customjs_callback_attributes_js_for_cb_data(self):
'data["y1"] = cb_data["geometry"]["y1"];\n')
self.assertEqual(js_code, code)


def test_callback_on_ndoverlay_is_attached(self):
ndoverlay = NdOverlay({i: Curve([i]) for i in range(5)})
selection = Selection1D(source=ndoverlay)
plot = bokeh_renderer.get_plot(ndoverlay)
self.assertEqual(len(plot.callbacks), 1)
self.assertIsInstance(plot.callbacks[0], Selection1DCallback)


@attr(optional=1)
class TestBokehServerJSCallbacks(ComparisonTestCase):

Expand Down

0 comments on commit 9aee63f

Please sign in to comment.