question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError: 'show_bounds' when setting projection

See original GitHub issue

ALL software version info

geoviews 1.7.0a3 bokeh 1.4.0

Description of expected behavior and the observed behavior

Complete, minimal, self-contained example code that reproduces the issue

This will plot correctly:

gv.Polygons([[[-88.8, 1], [-88.81, 30], [-60, 30], [-60, 1]]], crs=crs.PlateCarree())

But this will throw an error:

gv.Polygons([[[-88.8, 1], [-88.81, 30], [-60, 30], [-60, 1]]], crs=crs.PlateCarree()).opts(opts.Polygons(projection=crs.Robinson()))

Stack traceback and/or browser JavaScript console output

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/IPython/core/formatters.py in __call__(self, obj, include, exclude)
    968 
    969             if method is not None:
--> 970                 return method(include=include, exclude=exclude)
    971             return None
    972         else:

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/holoviews/core/dimension.py in _repr_mimebundle_(self, include, exclude)
   1295         combined and returned.
   1296         """
-> 1297         return Store.render(self)
   1298 
   1299 

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/holoviews/core/options.py in render(cls, obj)
   1386         data, metadata = {}, {}
   1387         for hook in hooks:
-> 1388             ret = hook(obj)
   1389             if ret is None:
   1390                 continue

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/holoviews/ipython/display_hooks.py in pprint_display(obj)
    280     if not ip.display_formatter.formatters['text/plain'].pprint:
    281         return None
--> 282     return display(obj, raw_output=True)
    283 
    284 

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/holoviews/ipython/display_hooks.py in display(obj, raw_output, **kwargs)
    250     elif isinstance(obj, (CompositeOverlay, ViewableElement)):
    251         with option_state(obj):
--> 252             output = element_display(obj)
    253     elif isinstance(obj, (Layout, NdLayout, AdjointLayout)):
    254         with option_state(obj):

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/holoviews/ipython/display_hooks.py in wrapped(element)
    144         try:
    145             max_frames = OutputSettings.options['max_frames']
--> 146             mimebundle = fn(element, max_frames=max_frames)
    147             if mimebundle is None:
    148                 return {}, {}

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/holoviews/ipython/display_hooks.py in element_display(element, max_frames)
    190         return None
    191 
--> 192     return render(element)
    193 
    194 

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/holoviews/ipython/display_hooks.py in render(obj, **kwargs)
     66         renderer = renderer.instance(fig='png')
     67 
---> 68     return renderer.components(obj, **kwargs)
     69 
     70 

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/holoviews/plotting/renderer.py in components(self, obj, fmt, comm, **kwargs)
    361             doc = Document()
    362             with config.set(embed=embed):
--> 363                 model = plot.layout._render_model(doc, comm)
    364             return render_model(model, comm) if embed else render_mimebundle(model, doc, comm)
    365         else:

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/panel/viewable.py in _render_model(self, doc, comm)
    355         if comm is None:
    356             comm = state._comm_manager.get_server_comm()
--> 357         model = self.get_root(doc, comm)
    358 
    359         if config.embed:

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/panel/viewable.py in get_root(self, doc, comm)
    526         """
    527         doc = doc or _curdoc()
--> 528         root = self._get_model(doc, comm=comm)
    529         self._preprocess(root)
    530         ref = root.ref['id']

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/panel/layout.py in _get_model(self, doc, root, parent, comm)
    134         if root is None:
    135             root = model
--> 136         objects = self._get_objects(model, [], doc, root, comm)
    137         props = dict(self._init_properties(), objects=objects)
    138         model.update(**self._process_param_change(props))

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/panel/layout.py in _get_objects(self, model, old_objects, doc, root, comm)
    124             else:
    125                 try:
--> 126                     child = pane._get_model(doc, root, model, comm)
    127                 except RerenderError:
    128                     return self._get_objects(model, current_objects[:i], doc, root, comm)

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/panel/pane/holoviews.py in _get_model(self, doc, root, parent, comm)
    225             plot = self.object
    226         else:
--> 227             plot = self._render(doc, comm, root)
    228 
    229         plot.pane = self

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/panel/pane/holoviews.py in _render(self, doc, comm, root)
    284             kwargs = {}
    285 
--> 286         return renderer.get_plot(self.object, **kwargs)
    287 
    288     def _cleanup(self, root):

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/holoviews/plotting/bokeh/renderer.py in get_plot(self_or_cls, obj, doc, renderer, **kwargs)
     70         combining the bokeh model with another plot.
     71         """
---> 72         plot = super(BokehRenderer, self_or_cls).get_plot(obj, doc, renderer, **kwargs)
     73         if plot.document is None:
     74             plot.document = Document() if self_or_cls.notebook_context else curdoc()

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/holoviews/plotting/renderer.py in get_plot(self_or_cls, obj, doc, renderer, comm, **kwargs)
    215             plot_opts = dict(self_or_cls.plot_options(obj, self_or_cls.size),
    216                              **kwargs)
--> 217             plot = self_or_cls.plotting_class(obj)(obj, renderer=renderer,
    218                                                    **plot_opts)
    219             defaults = [kd.default for kd in plot.dimensions]

//miniconda3/envs/lsst_dev/lib/python3.8/site-packages/geoviews/plotting/bokeh/plot.py in __init__(self, element, **params)
     66             show_bounds = self._traverse_options(element, 'plot', ['show_bounds'],
     67                                                  defaults=False)
---> 68             self.show_bounds = not any(not sb for sb in show_bounds['show_bounds'])
     69             if self.show_grid:
     70                 param.main.warning(

KeyError: 'show_bounds'

I’ll also note that running the broken code above on gv 1.6.6 does not throw an error

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
philippjfrcommented, Mar 22, 2020

Note that this is already fixed on master.

1reaction
philippjfrcommented, Mar 22, 2020

Thanks. I’ll release a fix later today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

KeyError: 'projection' when saving plot - GeoViews
I get this same error when running Projections.ipynb with ... Document() 364 with config.set(embed=embed): --> 365 model = plot.layout.
Read more >
How to Fix KeyError Exceptions in Python
When an item in a dictionary is accessed using a key, and the key is not found within the set of keys of...
Read more >
Python KeyError Exceptions and How to Handle Them
In this tutorial, you'll learn how to handle Python KeyError exceptions. ... A mapping is a data structure that maps one set of...
Read more >
Getting error KeyError: 'name_long' for 'country' 'records ...
Your country is a Record as given by the documentation for shapereader. Records have Attributes which is just a plain dictionary. Whatever data ......
Read more >
KeyError running python script that aligns the grid cells of ...
You have a logic error here: else: raise KeyError('Error setting output data type'). Remove this. Why? If your datatype is int or byte...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found