Repository: bokeh/bokeh

Issue:
selection_update stack trace when doing pan/zoom/select ops
After a minute or two of exploring the `selection_update.py` example with pan/zoom/select I got this stack trace.  I wasn't able to reproduce it, but perhaps it is evident to bokeh devs what may have caused it.

```
$ python selection_update.py 
Using saved session configuration for http://localhost:5006/
To override, pass 'load_from_config=False' to Session
Traceback (most recent call last):
  File "selection_update.py", line 107, in <module>
    cursession().poll_document(curdoc(), 0.05)
  File "/Users/ijstokes/anaconda/lib/python2.7/site-packages/bokeh/session.py", line 677, in poll_document
    self.load_document(document)
  File "/Users/ijstokes/anaconda/lib/python2.7/site-packages/bokeh/session.py", line 570, in load_document
    doc.merge(json_objs)
  File "/Users/ijstokes/anaconda/lib/python2.7/site-packages/bokeh/document.py", line 395, in merge
    self.load(plot_context_json, *other_objects)
  File "/Users/ijstokes/anaconda/lib/python2.7/site-packages/bokeh/document.py", line 245, in load
    self.execute_callback_queue(all_models-new_models)
  File "/Users/ijstokes/anaconda/lib/python2.7/site-packages/bokeh/document.py", line 345, in execute_callback_queue
    m._trigger(*cb)
  File "/Users/ijstokes/anaconda/lib/python2.7/site-packages/bokeh/plot_object.py", line 298, in _trigger
    fn(self, attrname, old, new)
  File "selection_update.py", line 97, in on_selection_change
    ph_source2.data["top"] = -hhist2
TypeError: bad operand type for unary -: 'list'
```



Discussion:
Somehow this was fixed and the fix got lost. The problem is just these two lines:

https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/selection_update.py#L50
https://github.com/bokeh/bokeh/blob/master/examples/plotting/server/selection_update.py#L64

The comprehensions need to be wrapped in `np.array` or (better) use `np.zeros` so that those two variables are actual numpy arrays. @ijstokes can you submit a PR to fix this?


Resolving patch:
diff --git a/examples/plotting/server/selection_update.py b/examples/plotting/server/selection_histogram.py
similarity index 95%
rename from examples/plotting/server/selection_update.py
rename to examples/plotting/server/selection_histogram.py
--- a/examples/plotting/server/selection_update.py
+++ b/examples/plotting/server/selection_histogram.py
@@ -5,8 +5,8 @@
 
 from bokeh.models import BoxSelectTool, HBox, LassoSelectTool, Paragraph, VBox
 from bokeh.plotting import (
-        curdoc, cursession, figure, output_server, show, _deduplicate_plots, _push_or_save
-    )
+    curdoc, cursession, figure, output_server, show, _deduplicate_plots, _push_or_save
+)
 
 # TODO (bev): remove these when plotting.py is fixed up to work better
 def hbox(*children, **kwargs):
@@ -29,7 +29,7 @@ def vbox(*children, **kwargs):
 y = np.random.normal(size=N) * 100
 all_inds = np.arange(len(x))
 
-output_server("selection_update")
+output_server("selection_histogram")
 
 TOOLS="pan,wheel_zoom,box_select,lasso_select"
 
@@ -47,7 +47,7 @@ def vbox(*children, **kwargs):
 
 # create the horizontal histogram
 hhist, hedges = np.histogram(x, bins=20)
-hzeros = [0]*(len(hedges)-1)
+hzeros = np.zeros(len(hedges)-1)
 hmax = max(hhist)*1.1
 
 ph = figure(toolbar_location=None, plot_width=p.plot_width, plot_height=200, x_range=p.x_range, y_range=(-hmax, hmax), title=None, min_border=10, min_border_left=50)
@@ -61,7 +61,7 @@ def vbox(*children, **kwargs):
 
 # create the vertical histogram
 vhist, vedges = np.histogram(y, bins=20)
-vzeros = [0]*(len(vedges)-1)
+vzeros = np.zeros(len(vedges)-1)
 vmax = max(vhist)*1.1
 
 # need to adjust for toolbar height, unfortunately


Test patch: