Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Clearing lines from streamed data using ColumnDataSource fails if data is arrays #10023

Open
Lif3line opened this issue May 14, 2020 · 4 comments

Comments

@Lif3line
Copy link

Issue

When attempting to clear drawn lines from streamed data via source.stream(data, rollover=1) the clear doesn't work if the line's x and y are numpy arrays in the associated ColumnDataSource. Instead a new line is drawn using the last of the old data and the new data.

This is different to the behaviour if either x or y is a list.

Minimal Example

Tested under Windows 10 + Mozilla Firefox in Jupyter Lab with the following packages

python=3.7.7
bokeh=2.0.2
numpy=1.18.1
jupyterlab=1.2.6
@bokeh/jupyter_bokeh v1.2.0

Actual Example:

from bokeh.io import output_notebook, show, push_notebook
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure

import numpy as np

output_notebook()

notebook_url="http://localhost:8888"

p = figure(match_aspect=True)

source1 = ColumnDataSource(data={"x": [-1, 0], "y1": [-1, -1] })
p.line(x='x', y='y1', source=source1, line_width=6, legend_label="List Source", line_color="blue")

source2 = ColumnDataSource(data={"x": np.array([0, 1]), "y1": np.array([0, 0]) })
p.line(x='x', y='y1', source=source2, line_width=6, legend_label="Array Source", line_color="red")

source3 = ColumnDataSource(data={"x": np.array([1, 2]), "y1": [1, 1] })
p.line(x='x', y='y1', source=source3, line_width=6, legend_label="Array X, List Y", line_color="yellow")

source4 = ColumnDataSource(data={"x": [2, 3], "y1": np.array([2, 2]) })
p.line(x='x', y='y1', source=source4, line_width=6, legend_label="List X, Array Y", line_color="orange")

plot_handle = show(p, notebook_url=notebook_url, notebook_handle=True)

### Attempt to clear data
# Update list only source
source1.stream({"x": [4], "y1": [4]}, rollover=1)

# Update array only source
source2.stream({"x": np.array([4]), "y1": np.array([4])}, rollover=1)

# Update array x, list y source
source3.stream({"x": np.array([4]), "y1": [4]}, rollover=1)

# Update array x, list y source
source4.stream({"x": [4], "y1": np.array([4])}, rollover=1)

push_notebook(handle=plot_handle)

This raises a Javascript console warning: [bokeh] data source has columns of inconsistent lengths caused by the sources with mixed data types. Same behaviour exists when these are removed.

image

@bryevdv
Copy link
Member

bryevdv commented May 15, 2020

Noting first that I cannot reproduce any issue in classic notebook. Will have to try later with jupyterlab

@mattpap
Copy link
Contributor

mattpap commented May 15, 2020

Can't reproduce on Linux in jupyterlab in FF and Chrome. Maybe this is a Windows specific issue.

@Lif3line
Copy link
Author

Interesting, I found I had the same issue in a classic notebook. I tested in a fresh anaconda environment with the following:

python=3.8.2
bokeh=2.0.2
numpy=1.18.4
notebook=6.0.3

@Lif3line
Copy link
Author

Can confirm that I don't get the same issue under Ubuntu 18.04, using the same clean environemnt. Agreed - it appears to be Windows specific.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants