Skip to content

Commit

Permalink
Improved handling for datashading empty objects
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Feb 15, 2018
1 parent c0a6fce commit 1457cc9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion holoviews/operation/datashader.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def get_agg_data(cls, obj, category=None):
paths = [p.compute() if isinstance(p, dd.DataFrame) else p for p in paths]
df = pd.concat(paths)
else:
df = paths[0]
df = paths[0] if paths else pd.DataFrame([], columns=[x.name, y.name])
if category and df[category].dtype.name != 'category':
df[category] = df[category].astype('category')

Expand Down Expand Up @@ -360,6 +360,10 @@ def _process(self, element, key=None):
xarray = xr.DataArray(np.full((height, width), np.NaN, dtype=np.float32),
dims=['y', 'x'], coords={'x': xs, 'y': ys})
return self.p.element_type(xarray)
elif not len(data):
xarray = xr.DataArray(np.full((height, width), np.NaN, dtype=np.float32),
dims=[y.name, x.name], coords={x.name: xs, y.name: ys})
return self.p.element_type(xarray)

cvs = ds.Canvas(plot_width=width, plot_height=height,
x_range=x_range, y_range=y_range)
Expand Down

0 comments on commit 1457cc9

Please sign in to comment.