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

Support responsive=True, data_aspect=True, and datashader operations #5425

Closed
hoxbro opened this issue Sep 6, 2022 · 0 comments · Fixed by #5808
Closed

Support responsive=True, data_aspect=True, and datashader operations #5425

hoxbro opened this issue Sep 6, 2022 · 0 comments · Fixed by #5808
Labels
type: bug Something isn't correct or isn't working

Comments

@hoxbro
Copy link
Member

hoxbro commented Sep 6, 2022

Is your feature request related to a problem? Please describe.

I will like to be able to use responsive=True, data_aspect=True, and datashader operations. Right now, this raises a TypeError. See the example below.

This could be seen as a bug, but I will mark it as a feature request.

Additional context

Code
import xarray as xr
import numpy as np
import holoviews as hv
from holoviews.operation.datashader import rasterize

hv.extension("bokeh")

da = xr.DataArray(
    np.arange(10000).reshape(100, 100),
    coords=dict(
        x=np.linspace(0, 3000, 100), y=np.linspace(0, 3000, 100)
    ),
)

image = hv.Image(da).opts(responsive=True, data_aspect=True)
image

rasterize(image)
Traceback
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File ~/miniconda3/envs/holoviz/lib/python3.9/site-packages/IPython/core/formatters.py:973, in MimeBundleFormatter.__call__(self, obj, include, exclude)
    970     method = get_real_method(obj, self.print_method)
    972     if method is not None:
--> 973         return method(include=include, exclude=exclude)
    974     return None
    975 else:

File ~/Development/holoviz/repos/holoviews/holoviews/core/dimension.py:1294, in Dimensioned._repr_mimebundle_(self, include, exclude)
   1287 def _repr_mimebundle_(self, include=None, exclude=None):
   1288     """
   1289     Resolves the class hierarchy for the class rendering the
   1290     object using any display hooks registered on Store.display
   1291     hooks.  The output of all registered display_hooks is then
   1292     combined and returned.
   1293     """
-> 1294     return Store.render(self)

File ~/Development/holoviz/repos/holoviews/holoviews/core/options.py:1418, in Store.render(cls, obj)
   1416 data, metadata = {}, {}
   1417 for hook in hooks:
-> 1418     ret = hook(obj)
   1419     if ret is None:
   1420         continue

File ~/Development/holoviz/repos/holoviews/holoviews/ipython/display_hooks.py:277, in pprint_display(obj)
    275 if not ip.display_formatter.formatters['text/plain'].pprint:
    276     return None
--> 277 return display(obj, raw_output=True)

File ~/Development/holoviz/repos/holoviews/holoviews/ipython/display_hooks.py:253, in display(obj, raw_output, **kwargs)
    251 elif isinstance(obj, (HoloMap, DynamicMap)):
    252     with option_state(obj):
--> 253         output = map_display(obj)
    254 elif isinstance(obj, Plot):
    255     output = render(obj)

File ~/Development/holoviz/repos/holoviews/holoviews/ipython/display_hooks.py:141, in display_hook.<locals>.wrapped(element)
    139 try:
    140     max_frames = OutputSettings.options['max_frames']
--> 141     mimebundle = fn(element, max_frames=max_frames)
    142     if mimebundle is None:
    143         return {}, {}

File ~/Development/holoviz/repos/holoviews/holoviews/ipython/display_hooks.py:201, in map_display(vmap, max_frames)
    198     max_frame_warning(max_frames)
    199     return None
--> 201 return render(vmap)

File ~/Development/holoviz/repos/holoviews/holoviews/ipython/display_hooks.py:68, in render(obj, **kwargs)
     65 if renderer.fig == 'pdf':
     66     renderer = renderer.instance(fig='png')
---> 68 return renderer.components(obj, **kwargs)

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/renderer.py:398, in Renderer.components(self, obj, fmt, comm, **kwargs)
    395 embed = (not (dynamic or streams or self.widget_mode == 'live') or config.embed)
    397 if embed or config.comms == 'default':
--> 398     return self._render_panel(plot, embed, comm)
    399 return self._render_ipywidget(plot)

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/renderer.py:405, in Renderer._render_panel(self, plot, embed, comm)
    403 doc = Document()
    404 with config.set(embed=embed):
--> 405     model = plot.layout._render_model(doc, comm)
    406 if embed:
    407     return render_model(model, comm)

File ~/Development/holoviz/repos/panel/panel/viewable.py:507, in Renderable._render_model(self, doc, comm)
    505 if comm is None:
    506     comm = state._comm_manager.get_server_comm()
--> 507 model = self.get_root(doc, comm)
    509 if config.embed:
    510     embed_state(self, model, doc,
    511                 json=config.embed_json,
    512                 json_prefix=config.embed_json_prefix,
    513                 save_path=config.embed_save_path,
    514                 load_path=config.embed_load_path,
    515                 progress=False)

File ~/Development/holoviz/repos/panel/panel/viewable.py:558, in Renderable.get_root(self, doc, comm, preprocess)
    541 """
    542 Returns the root model and applies pre-processing hooks
    543 
   (...)
    555 Returns the bokeh model corresponding to this panel object
    556 """
    557 doc = init_doc(doc)
--> 558 root = self._get_model(doc, comm=comm)
    559 if preprocess:
    560     self._preprocess(root)

File ~/Development/holoviz/repos/panel/panel/layout/base.py:146, in Panel._get_model(self, doc, root, parent, comm)
    144 if root is None:
    145     root = model
--> 146 objects = self._get_objects(model, [], doc, root, comm)
    147 props = dict(self._init_params(), objects=objects)
    148 model.update(**self._process_param_change(props))

File ~/Development/holoviz/repos/panel/panel/layout/base.py:131, in Panel._get_objects(self, model, old_objects, doc, root, comm)
    129 else:
    130     try:
--> 131         child = pane._get_model(doc, root, model, comm)
    132     except RerenderError:
    133         return self._get_objects(model, current_objects[:i], doc, root, comm)

File ~/Development/holoviz/repos/panel/panel/pane/holoviews.py:265, in HoloViews._get_model(self, doc, root, parent, comm)
    263     plot = self.object
    264 else:
--> 265     plot = self._render(doc, comm, root)
    267 plot.pane = self
    268 backend = plot.renderer.backend

File ~/Development/holoviz/repos/panel/panel/pane/holoviews.py:342, in HoloViews._render(self, doc, comm, root)
    339     if comm:
    340         kwargs['comm'] = comm
--> 342 return renderer.get_plot(self.object, **kwargs)

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/bokeh/renderer.py:70, in BokehRenderer.get_plot(self_or_cls, obj, doc, renderer, **kwargs)
     63 @bothmethod
     64 def get_plot(self_or_cls, obj, doc=None, renderer=None, **kwargs):
     65     """
     66     Given a HoloViews Viewable return a corresponding plot instance.
     67     Allows supplying a document attach the plot to, useful when
     68     combining the bokeh model with another plot.
     69     """
---> 70     plot = super().get_plot(obj, doc, renderer, **kwargs)
     71     if plot.document is None:
     72         plot.document = Document() if self_or_cls.notebook_context else curdoc()

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/renderer.py:254, in Renderer.get_plot(self_or_cls, obj, doc, renderer, comm, **kwargs)
    252     p._trigger = []
    253 for trigger in triggers:
--> 254     Stream.trigger([trigger])
    256 if isinstance(self_or_cls, Renderer):
    257     self_or_cls.last_plot = plot

File ~/Development/holoviz/repos/holoviews/holoviews/streams.py:184, in Stream.trigger(cls, streams)
    182 with triggering_streams(streams):
    183     for subscriber in subscribers:
--> 184         subscriber(**dict(union))
    186 for stream in streams:
    187     with util.disable_constant(stream):

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/plot.py:243, in Plot.refresh(self, **kwargs)
    241         self.push()
    242 except Exception as e:
--> 243     raise e
    244 finally:
    245     # Reset triggering state
    246     for s in self._triggering:

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/plot.py:239, in Plot.refresh(self, **kwargs)
    234 key = tuple(None if d in stream_params else k
    235             for d, k in zip(self.dimensions, key))
    236 stream_key = util.wrap_tuple_streams(key, self.dimensions, self.streams)
--> 239 self._trigger_refresh(stream_key)
    240 if self.top_level:
    241     self.push()

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/plot.py:256, in Plot._trigger_refresh(self, key)
    254 if not self.top_level or isinstance(self, GenericElementPlot):
    255     with unlocked():
--> 256         self.update(key)

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/plot.py:949, in DimensionedPlot.update(self, key)
    947 if len(self) == 1 and ((key == 0) or (key == self.keys[0])) and not self.drawn:
    948     return self.initialize_plot()
--> 949 item = self.__getitem__(key)
    950 self.traverse(lambda x: setattr(x, '_updated', True))
    951 return item

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/plot.py:435, in DimensionedPlot.__getitem__(self, frame)
    433 if not isinstance(frame, tuple):
    434     frame = self.keys[frame]
--> 435 self.update_frame(frame)
    436 return self.state

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/bokeh/element.py:1520, in ElementPlot.update_frame(self, key, ranges, plot, element)
   1518 plot = self.handles['plot']
   1519 if not self.overlaid:
-> 1520     self._update_ranges(style_element, ranges)
   1521     self._update_plot(key, plot, style_element)
   1522     self._set_active_tools(plot)

File ~/Development/holoviz/repos/holoviews/holoviews/plotting/bokeh/element.py:835, in ElementPlot._update_ranges(self, element, ranges)
    833     frame_aspect = self.aspect
    834 else:
--> 835     frame_aspect = plot.frame_height/plot.frame_width
    837 if self.drawn:
    838     current_l, current_r = plot.x_range.start, plot.x_range.end

TypeError: unsupported operand type(s) for /: 'NoneType' and 'NoneType'

image

@hoxbro hoxbro added the type: feature A major new feature label Sep 6, 2022
@philippjfr philippjfr added type: bug Something isn't correct or isn't working and removed type: feature A major new feature labels Sep 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants