Skip to content

Commit

Permalink
Handle datashader zero-sized array reduction
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Oct 8, 2017
1 parent 83173d1 commit f11555c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions holoviews/operation/datashader.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,21 @@ def _get_sampling(self, element, x, y):
y0, y1 = self.p.y_range
ey0, ey1 = element.range(y)
y_range = max([y0, ey0]), min([y1, ey1])
if y_range[0] == y_range[1]:
y_range = (y_range[0]-0.5, y_range[0]+0.5)
width, height = self.p.width, self.p.height
(xstart, xend), (ystart, yend) = x_range, y_range

if not np.isfinite(xstart) and not np.isfinite(xend):
xstart, xend = 0, 1
elif xstart == xend:
xstart, xend = (xstart-0.5, xend+0.5)
x_range = (xstart, xend)

if not np.isfinite(ystart) and not np.isfinite(yend):
ystart, yend = 0, 1
elif ystart == yend:
ystart, yend = (ystart-0.5, yend+0.5)
y_range = (ystart, yend)

# Compute highest allowed sampling density
xspan = xend - xstart
yspan = yend - ystart
Expand All @@ -135,6 +145,7 @@ def _get_sampling(self, element, x, y):
xunit, yunit = float(xspan)/width, float(yspan)/height
xs, ys = (np.linspace(xstart+xunit/2., xend-xunit/2., width),
np.linspace(ystart+yunit/2., yend-yunit/2., height))

return (x_range, y_range), (xs, ys), (width, height)


Expand Down

0 comments on commit f11555c

Please sign in to comment.