Skip to content

Commit

Permalink
Added unit test to check streams on batched plots are linked
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 15, 2017
1 parent 9b2bad5 commit 0daeb70
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions tests/testplotinstantiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
try:
from holoviews.plotting.bokeh.util import bokeh_version
bokeh_renderer = Store.renderers['bokeh']
from holoviews.plotting.bokeh.callbacks import Callback
from holoviews.plotting.bokeh.callbacks import Callback, PointerXCallback
from bokeh.models import (
Div, ColumnDataSource, FactorRange, Range1d, Row, Column,
ToolbarBox, FixedTicker, FuncTickFormatter
Expand Down Expand Up @@ -97,7 +97,7 @@ def setUp(self):
self.default_comm = mpl_renderer.comms['default']
mpl_renderer.comms['default'] = (comms.Comm, '')

def teardown(self):
def tearDown(self):
mpl_renderer.comms['default'] = self.default_comm
Store.current_backend = self.previous_backend

Expand Down Expand Up @@ -324,10 +324,11 @@ def setUp(self):
self.default_comm = bokeh_renderer.comms['default']
bokeh_renderer.comms['default'] = (comms.Comm, '')

def teardown(self):
def tearDown(self):
Store.current_backend = self.previous_backend
Callback._comm_type = comms.JupyterCommJS
mpl_renderer.comms['default'] = self.default_comm
Callback._callbacks = {}

def test_overlay_legend(self):
overlay = Curve(range(10), label='A') * Curve(range(10), label='B')
Expand Down Expand Up @@ -404,6 +405,20 @@ def test_batched_curve_subscribers_correctly_attached(self):
self.assertIn(plot.refresh, posx.subscribers)
self.assertNotIn(list(plot.subplots.values())[0].refresh, posx.subscribers)

def test_batched_curve_subscribers_correctly_linked(self):
# Checks if a stream callback is created to link batched plot
# to the stream
posx = PointerX()
opts = {'NdOverlay': dict(plot=dict(legend_limit=0)),
'Curve': dict(style=dict(line_color=Cycle(values=['red', 'blue'])))}
overlay = DynamicMap(lambda x: NdOverlay({i: Curve([(i, j) for j in range(2)])
for i in range(2)})(opts), kdims=[],
streams=[posx])
plot = bokeh_renderer.get_plot(overlay)
self.assertEqual(len(Callback._callbacks), 1)
key = list(Callback._callbacks.keys())[0]
self.assertEqual(key, (id(plot.handles['plot']), id(PointerXCallback)))

def test_batched_points_size_and_color(self):
opts = {'NdOverlay': dict(plot=dict(legend_limit=0)),
'Points': dict(style=dict(size=Cycle(values=[1, 2])))}
Expand Down Expand Up @@ -1425,7 +1440,7 @@ def setUp(self):
plotly_renderer.comms['default'] = (comms.Comm, '')


def teardown(self):
def tearDown(self):
Store.current_backend = self.previous_backend
plotly_renderer.comms['default'] = self.default_comm

Expand Down

0 comments on commit 0daeb70

Please sign in to comment.