You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of expected behavior and the observed behavior
If a plot, such as Scatter, has its range modified using redim prior to being datashaded
(e.g.datashade(hv.Scatter(df, 'x', 'y').redim(y=hv.Dimension('y', range=(-0.5,1.5)))) ),
an error is thrown. This should not cause an error, and worked prior to holoviews 1.13.0.
Conditions for this error behavior:
holoviews>=1.13.0
Deployed using bokeh serve (Same error when deployed using panel.show() if using panel library)
redim used to modify range values
This error does not occur if any of the following are true:
holoviews<1.13.0
Run in a Jupyter notebook
redim does not modify range (e.g. hv.Scatter(df, 'x', 'y').redim(y=hv.Dimension('y2')))
Complete, minimal, self-contained example code that reproduces the issue
# minimal_example.py
import holoviews as hv
import numpy as np
import pandas as pd
from holoviews.operation.datashader import datashade
hv.extension('bokeh')
renderer = hv.renderer('bokeh')
# Create dummy dataset
num_pts = 1000
df = pd.DataFrame({'x':np.linspace(0,100,num_pts), 'y':np.random.random(num_pts)})
# Create scatterplot
hv_plot = hv.Scatter(df, 'x', 'y')
# Redim range (THIS IS THE LINE THAT CAUSES AN ERROR)
hv_plot = hv_plot.redim(y=hv.Dimension('y', range=(-0.5,1.5)))
# Datashade the scatter plot
datashaded_plot = datashade(hv_plot)
# Create bokeh doc
doc = renderer.server_doc(datashaded_plot)
# Run example using 'bokeh serve --show minimal_example.py' from console
bokeh.application.application - ERROR - Error running application handler <bokeh.application.handlers.script.ScriptHandler object at 0x7f58c595dcd0>: 'NoneType' object has no attribute 'session_context'
File "plot.py", line 218, in refresh:
if self.document.session_context: Traceback (most recent call last):
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/bokeh/application/handlers/code_runner.py", line 197, in run
exec(self._code, module.__dict__)
File "/home/user/Documents/panel_viz/bin/minimal_example.py", line 25, in <module>
doc = renderer.server_doc(datashaded_plot)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/holoviews/plotting/renderer.py", line 466, in server_doc
return obj.layout.server_doc(doc)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/panel/viewable.py", line 600, in server_doc
model = self.get_root(doc)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/panel/viewable.py", line 536, in get_root
root = self._get_model(doc, comm=comm)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/panel/layout.py", line 136, in _get_model
objects = self._get_objects(model, [], doc, root, comm)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/panel/layout.py", line 126, in _get_objects
child = pane._get_model(doc, root, model, comm)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/panel/pane/holoviews.py", line 227, in _get_model
plot = self._render(doc, comm, root)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/panel/pane/holoviews.py", line 286, in _render
return renderer.get_plot(self.object, **kwargs)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/holoviews/plotting/bokeh/renderer.py", line 73, in get_plot
plot = super(BokehRenderer, self_or_cls).get_plot(obj, doc, renderer, **kwargs)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/holoviews/plotting/renderer.py", line 223, in get_plot
plot.update(init_key)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/holoviews/plotting/plot.py", line 878, in update
return self.initialize_plot()
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/holoviews/plotting/bokeh/element.py", line 1334, in initialize_plot
Stream.trigger(trigger)
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/holoviews/streams.py", line 169, in trigger
subscriber(**dict(union))
File "/home/user/anaconda3/envs/bokeh-dev/lib/python3.7/site-packages/holoviews/plotting/plot.py", line 218, in refresh
if self.document.session_context:
AttributeError: 'NoneType' object has no attribute 'session_context'
The text was updated successfully, but these errors were encountered:
mmorys
changed the title
Not attribute 'session_context' with redim range and datashade
No attribute 'session_context' with redim range and datashade
Mar 31, 2020
We'll have to update the docs, I would not recommend using renderer.server_doc at this point (although it should be fixed for backward compatibility). Instead I'd use panel:
Software version info
Ubuntu 18.04
python 3.7.6
bokeh 2.0.1
holoviews 1.13.1
notebook 6.0.3
browser: Chromium 80.0.3987.149
Description of expected behavior and the observed behavior
If a plot, such as Scatter, has its range modified using
redim
prior to being datashaded(e.g.
datashade(hv.Scatter(df, 'x', 'y').redim(y=hv.Dimension('y', range=(-0.5,1.5))))
),an error is thrown. This should not cause an error, and worked prior to holoviews 1.13.0.
Conditions for this error behavior:
bokeh serve
(Same error when deployed usingpanel.show()
if usingpanel
library)This error does not occur if any of the following are true:
hv.Scatter(df, 'x', 'y').redim(y=hv.Dimension('y2'))
)Complete, minimal, self-contained example code that reproduces the issue
Stack traceback and/or browser JavaScript console output
The text was updated successfully, but these errors were encountered: