Hi all, I’m getting my feet wet with Bokeh and have been impressed by it overall. My main use case is from within a Jupyter notebook; I’ll write a report or simple dashboard as a Jupyter notebook, and often export to HTML to share with others. Bokeh’s interactive panning and zooming is extremely useful for this.

Recently I tried adding some custom interactive features, and ran into problems understanding how push_notebook is supposed to work. I’ll start by making a scatter plot based on a CDSView data source; after the plot’s been inserted into the notebook, I’ll update the filters on the CDSView object and then call push_notebook. Depending on exactly what I do, this either throws an exception, or does nothing. There’s an example below.

Why does push_notebook not see changes to the filters on a CDSView object?

Thanks for any suggestions!

# In[1]:

import pandas as pd

import bokeh

from bokeh.io import output_notebook, push_notebook, save, show

from bokeh.models import CDSView, ColumnDataSource, BooleanFilter

from bokeh.plotting import figure

output_notebook()

# In[2]:

data = pd.DataFrame(

{

‘x’: [0, 1, 2, 3],

‘y’: [1, 2, 1, 2],

}

)

# In[3]:

fltr = BooleanFilter([True] * len(data))

# In[4]:

source = ColumnDataSource(data)

view = CDSView(source=source, filters=[fltr])

# In[5]:

f = figure(plot_height=300, plot_width=300)

circles = f.circle(x=‘x’, y=‘y’, source=source, view=view,)

t = show(f, notebook_handle=True)

# Out[5] shows the expected scatter plot, with four points

# In[6]:

t

# Out[6]: <Bokeh Notebook handle for **In[5]**>

# In[7]:

circles.view.filters[0].booleans

# Out[7]: [True, True, True, True]

# In[8]:

fltr.booleans[0] = False

# In[9]:

circles.view.filters[0].booleans

# Out[9]: [False, True, True, True]

# In[10]:

push_notebook(handle=t)

# This causes “ValueError: PATCH-DOC message requires at least one event”

# In[11]:

fltr.booleans = [False] * len(data)

# In[12]:

push_notebook(handle=t)

# This does not cause an exception, but the plot in Out[5] does not change

# In[13]:

f = figure(plot_height=300, plot_width=300)

circles = f.circle(x=‘x’, y=‘y’, source=source, view=view,)

t = show(f, notebook_handle=True)

# This shows a new, empty plot, as expected

``