Avoid KeyError when overlaying dynamic groupbys #5603
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
WIP
Here is the test example:
With this PR you can select
CAT2
:On
main
you get a keyerror:During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/pyviz_comms/init.py", line 338, in _handle_msg
self._on_msg(msg)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/panel/viewable.py", line 294, in _on_msg
doc.unhold()
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/bokeh/document/document.py", line 799, in unhold
self.callbacks.unhold()
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/bokeh/document/callbacks.py", line 396, in unhold
self.trigger_on_change(event)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/bokeh/document/callbacks.py", line 373, in trigger_on_change
invoke_with_curdoc(doc, event.callback_invoker)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/bokeh/document/callbacks.py", line 408, in invoke_with_curdoc
return f()
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/bokeh/util/callback_manager.py", line 191, in invoke
callback(attr, old, new)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/panel/reactive.py", line 405, in _comm_change
state._handle_exception(e)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/panel/io/state.py", line 391, in _handle_exception
raise exception
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/panel/reactive.py", line 403, in _comm_change
self._schedule_change(doc, comm)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/panel/reactive.py", line 385, in _schedule_change
self._change_event(doc)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/panel/reactive.py", line 381, in _change_event
self._process_events(events)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/panel/reactive.py", line 319, in process_events
self.param.update(**self_events)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/param/parameterized.py", line 1898, in update
self._batch_call_watchers()
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/param/parameterized.py", line 2059, in batch_call_watchers
self._execute_watcher(watcher, events)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/param/parameterized.py", line 2021, in _execute_watcher
watcher.fn(*args, **kwargs)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/panel/pane/holoviews.py", line 240, in _widget_callback
self._update_plot(plot, pane)
File "/Users/jstevens/miniconda3/envs/analytics/lib/python3.7/site-packages/panel/pane/holoviews.py", line 222, in _update_plot
plot.update(key)
File "/Users/jstevens/Desktop/development/holoviews/holoviews/plotting/plot.py", line 937, in update
item = self.getitem(key)
File "/Users/jstevens/Desktop/development/holoviews/holoviews/plotting/plot.py", line 423, in getitem
self.update_frame(frame)
File "/Users/jstevens/Desktop/development/holoviews/holoviews/plotting/bokeh/element.py", line 2432, in update_frame
defaults=False)
File "/Users/jstevens/Desktop/development/holoviews/holoviews/plotting/plot.py", line 890, in _traverse_options
traversed = obj.traverse(lookup, specs)
File "/Users/jstevens/Desktop/development/holoviews/holoviews/core/dimension.py", line 662, in traverse
accumulator += el.traverse(fn, specs, full_breadth)
File "/Users/jstevens/Desktop/development/holoviews/holoviews/core/dimension.py", line 655, in traverse
accumulator.append(fn(self))
File "/Users/jstevens/Desktop/development/holoviews/holoviews/plotting/plot.py", line 879, in lookup
options = cls.lookup_options(x, opt_type)
File "/Users/jstevens/Desktop/development/holoviews/holoviews/plotting/plot.py", line 275, in lookup_options
return lookup_options(obj, group, cls.backend)
File "/Users/jstevens/Desktop/development/holoviews/holoviews/core/options.py", line 94, in lookup_options
plot_class = Store.renderers[backend].plotting_class(obj)
File "/Users/jstevens/Desktop/development/holoviews/holoviews/plotting/renderer.py", line 540, in plotting_class
raise SkipRendering(f"No plotting class for {element_type.name} found")
AttributeError: 'NoneType' object has no attribute 'name'
I thought I could return an empty element from the dynamicmap created by
groupby
in the.to
call but I always hit key errors in the plotting code until this change.