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

Should clearly report which element types are supported for datashading #2158

Closed
carlodri opened this issue Nov 28, 2017 · 6 comments
Closed
Assignees
Milestone

Comments

@carlodri
Copy link

carlodri commented Nov 28, 2017

If I write this simple code:

import numpy as np
import holoviews as hv
from holoviews.operation.datashader import datashade
hv.notebook_extension('bokeh')
image = np.random.rand(6000,6000)
image = hv.Raster(image)
datashade(image)

I get the following error:

WARNING:root:dynamic_operation: Exception raised in callable 'dynamic_operation' of type 'function'.
Invoked as dynamic_operation(height=400, scale=1.0, width=400, x_range=None, y_range=None)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
C:\Miniconda3x64\lib\site-packages\IPython\core\formatters.py in __call__(self, obj)
    339                 pass
    340             else:
--> 341                 return printer(obj)
    342             # Finally look for special method names
    343             method = get_real_method(obj, self.print_method)

C:\Miniconda3x64\lib\site-packages\holoviews\ipython\display_hooks.py in pprint_display(obj)
    257     if not ip.display_formatter.formatters['text/plain'].pprint:
    258         return None
--> 259     return display(obj, raw=True)
    260 
    261 

C:\Miniconda3x64\lib\site-packages\holoviews\ipython\display_hooks.py in display(obj, raw, **kwargs)
    243     elif isinstance(obj, (HoloMap, DynamicMap)):
    244         with option_state(obj):
--> 245             html = map_display(obj)
    246     else:
    247         return repr(obj) if raw else IPython.display.display(obj, **kwargs)

C:\Miniconda3x64\lib\site-packages\holoviews\ipython\display_hooks.py in wrapped(element)
    130         try:
    131             html = fn(element,
--> 132                       max_frames=OutputSettings.options['max_frames'])
    133 
    134             # Only want to add to the archive for one display hook...

C:\Miniconda3x64\lib\site-packages\holoviews\ipython\display_hooks.py in map_display(vmap, max_frames)
    198         return None
    199 
--> 200     return render(vmap)
    201 
    202 

C:\Miniconda3x64\lib\site-packages\holoviews\ipython\display_hooks.py in render(obj, **kwargs)
     60     if renderer.fig == 'pdf':
     61         renderer = renderer.instance(fig='png')
---> 62     return renderer.html(obj, **kwargs)
     63 
     64 

C:\Miniconda3x64\lib\site-packages\holoviews\plotting\renderer.py in html(self, obj, fmt, css, comm, **kwargs)
    255         code to initialize a Comm, if the plot supplies one.
    256         """
--> 257         plot, fmt =  self._validate(obj, fmt)
    258         figdata, _ = self(plot, fmt, **kwargs)
    259         if css is None: css = self.css

C:\Miniconda3x64\lib\site-packages\holoviews\plotting\renderer.py in _validate(self, obj, fmt)
    191         if isinstance(obj, tuple(self.widgets.values())):
    192             return obj, 'html'
--> 193         plot = self.get_plot(obj, renderer=self)
    194 
    195         fig_formats = self.mode_formats['fig'][self.mode]

C:\Miniconda3x64\lib\site-packages\holoviews\plotting\bokeh\renderer.py in get_plot(self_or_cls, obj, doc, renderer)
    114         combining the bokeh model with another plot.
    115         """
--> 116         plot = super(BokehRenderer, self_or_cls).get_plot(obj, renderer)
    117         if self_or_cls.mode == 'server' and doc is None:
    118             doc = curdoc()

C:\Miniconda3x64\lib\site-packages\holoviews\plotting\renderer.py in get_plot(self_or_cls, obj, renderer)
    164         """
    165         # Initialize DynamicMaps with first data item
--> 166         initialize_dynamic(obj)
    167 
    168         if not isinstance(obj, Plot):

C:\Miniconda3x64\lib\site-packages\holoviews\plotting\util.py in initialize_dynamic(obj)
    177             continue
    178         if not len(dmap):
--> 179             dmap[dmap._initial_key()]
    180 
    181 

C:\Miniconda3x64\lib\site-packages\holoviews\core\spaces.py in __getitem__(self, key)
   1024         # Not a cross product and nothing cached so compute element.
   1025         if cache is not None: return cache
-> 1026         val = self._execute_callback(*tuple_key)
   1027         if data_slice:
   1028             val = self._dataslice(val, data_slice)

C:\Miniconda3x64\lib\site-packages\holoviews\core\spaces.py in _execute_callback(self, *args)
    853 
    854         with dynamicmap_memoization(self.callback, self.streams):
--> 855             retval = self.callback(*args, **kwargs)
    856         return self._style(retval)
    857 

C:\Miniconda3x64\lib\site-packages\holoviews\core\spaces.py in __call__(self, *args, **kwargs)
    520 
    521         try:
--> 522             ret = self.callable(*args, **kwargs)
    523         except KeyError:
    524             # KeyError is caught separately because it is used to signal

C:\Miniconda3x64\lib\site-packages\holoviews\util\__init__.py in dynamic_operation(*key, **kwargs)
    343                 self.p.kwargs.update(kwargs)
    344                 obj = map_obj[key] if isinstance(map_obj, HoloMap) else map_obj
--> 345                 return self._process(obj, key)
    346         else:
    347             def dynamic_operation(*key, **kwargs):

C:\Miniconda3x64\lib\site-packages\holoviews\util\__init__.py in _process(self, element, key)
    329             kwargs = {k: v for k, v in self.p.kwargs.items()
    330                       if k in self.p.operation.params()}
--> 331             return self.p.operation.process_element(element, key, **kwargs)
    332         else:
    333             return self.p.operation(element, **self.p.kwargs)

C:\Miniconda3x64\lib\site-packages\holoviews\core\operation.py in process_element(self, element, key, **params)
    119         """
    120         self.p = param.ParamOverrides(self, params)
--> 121         return self._process(element, key)
    122 
    123 

C:\Miniconda3x64\lib\site-packages\holoviews\operation\datashader.py in _process(self, element, key)
    634 
    635     def _process(self, element, key=None):
--> 636         agg = aggregate._process(self, element, key)
    637         shaded = shade._process(self, agg, key)
    638         return shaded

C:\Miniconda3x64\lib\site-packages\holoviews\operation\datashader.py in _process(self, element, key)
    333             return self._aggregate_ndoverlay(element, agg_fn)
    334 
--> 335         x, y, data, glyph = self.get_agg_data(element, category)
    336         (x_range, y_range), (xs, ys), (width, height), (xtype, ytype) = self._get_sampling(element, x, y)
    337 

C:\Miniconda3x64\lib\site-packages\holoviews\operation\datashader.py in get_agg_data(cls, obj, category)
    219         elif isinstance(obj, Element):
    220             glyph = 'line' if isinstance(obj, Curve) else 'points'
--> 221             paths.append(PandasInterface.as_dframe(obj))
    222 
    223         if dims is None or len(dims) != 2:

C:\Miniconda3x64\lib\site-packages\holoviews\core\data\pandas.py in as_dframe(cls, dataset)
    263         if it already a dataframe type.
    264         """
--> 265         if issubclass(dataset.interface, PandasInterface):
    266             return dataset.data
    267         else:

AttributeError: 'Raster' object has no attribute 'interface'

Out[30]:
:DynamicMap   []

Can anyone help me to sort it out? Am I missing something? Is this a bug?

Using holoviews 1.9.1-x-gc1d66c015 and datashader 0.6.2

@philippjfr
Copy link
Member

Datashading is only supported for Image and RGB types and even then you should (for the time being use) shade(regrid(Image(...)) rather than using datashade directly.

@carlodri
Copy link
Author

ok thanks for the clarification, I searched the docs for a list of supported elements but I could not find this info...

@jbednar
Copy link
Member

jbednar commented Nov 28, 2017

That's a good point; we should add a list of which types are supported for datashading, and/or make a clearer error message for unsupported types. Reopening with a new title to remind us to do that...

@jbednar jbednar reopened this Nov 28, 2017
@jbednar jbednar changed the title Raster element and datashade error Should clearly report which element types are supported for datashading Nov 28, 2017
@jbednar jbednar added this to the v1.10 milestone Nov 28, 2017
@carlodri
Copy link
Author

that's surely helpful, thanks @jbednar !

@jlstevens
Copy link
Contributor

@jbednar @philippjfr How does this fit in with the idea of a more general datashading operation that can support more element types? I know this was discussed relatively recently and I might be out of the loop...

@philippjfr
Copy link
Member

I know this was discussed relatively recently and I might be out of the loop...

The trimesh PR makes a start on this, but I'm waiting on @jbednar to tidy up the API for raster regridding before that can be fully unified. However the rasterize operation will rasterize most common elements, nested in whatever way you want but will not apply to unsupported elements. Once that has been merged we can update the Large Data user guide.

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

No branches or pull requests

4 participants