Skip to content

Commit

Permalink
Fixes for bokeh server widgets (#2218)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 9, 2018
1 parent ee01893 commit bee286d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions holoviews/plotting/bokeh/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, plot, renderer=None, **params):
self.renderer = renderer
# Create mock NdMapping to hold the common dimensions and keys
self.mock_obj = NdMapping([(k, None) for k in self.keys],
kdims=self.dimensions)
kdims=list(self.dimensions))
self.widgets, self.lookups = self.get_widgets()
self.reverse_lookups = {d: {v: k for k, v in item.items()}
for d, item in self.lookups.items()}
Expand Down Expand Up @@ -195,11 +195,10 @@ def update(self):
Handle update events on bokeh server.
"""
if not self._queue:
self._active = False
return
self._queue = []

dim, widget_type, attr, old, new = self._queue[-1]
self._queue = []
dim_label = dim.pprint_label

label, widget = self.widgets[dim_label]
Expand Down Expand Up @@ -232,6 +231,7 @@ def update(self):
key = wrap_tuple_streams(tuple(key), self.plot.dimensions,
self.plot.streams)
self.plot.update(key)
self._active = False



Expand Down
15 changes: 14 additions & 1 deletion tests/testbokehwidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import numpy as np

from holoviews.core import Dimension, NdMapping
from holoviews import renderer
from holoviews.core import Dimension, NdMapping, DynamicMap
from holoviews.element import Curve
from holoviews.element.comparison import ComparisonTestCase

try:
Expand All @@ -18,6 +20,17 @@ def setUp(self):
if not BokehServerWidgets:
raise SkipTest("Bokeh required to test BokehServerWidgets")

def test_bokeh_widgets_server_mode(self):
dmap = DynamicMap(lambda X: Curve([]), kdims=['X']).redim.range(X=(0, 5))
widgets = renderer('bokeh').instance(mode='server').get_widget(dmap, None)
div, widget = widgets.widgets['X']
self.assertIsInstance(widget, Slider)
self.assertEqual(widget.value, 0)
self.assertEqual(widget.start, 0)
self.assertEqual(widget.end, 5)
self.assertEqual(widget.step, 1)
self.assertEqual(widgets.state.sizing_mode, 'fixed')

def test_bokeh_server_dynamic_range_int(self):
dim = Dimension('x', range=(3, 11))
widget, label, mapping = BokehServerWidgets.create_widget(dim, editable=True)
Expand Down

0 comments on commit bee286d

Please sign in to comment.