Skip to content

Commit

Permalink
Handle non-finite range in datashader operations (#2863)
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jul 7, 2018
1 parent 4dff5ea commit 2fa1c0a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ install:
- conda info -a
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION flake8 scipy=1.0.0 numpy freetype nose pandas=0.22.0 jupyter ipython=5.4.1 param matplotlib=2.1.2 xarray networkx
- source activate test-environment
- conda install -c conda-forge filelock iris plotly flexx ffmpeg netcdf4=1.3.1 --quiet
- conda install -c conda-forge filelock iris plotly=2.7 flexx ffmpeg netcdf4=1.3.1 --quiet
- conda install -c bokeh datashader dask bokeh=0.12.15 selenium
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.4" ]]; then
conda install python=3.4.3;
Expand Down
9 changes: 7 additions & 2 deletions holoviews/core/data/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,17 @@ def values(cls, dataset, dim, expanded=True, flat=True, compute=True):
if dim_idx in [0, 1]:
l, b, r, t = dataset.bounds.lbrt()
dim2, dim1 = dataset.data.shape[:2]
if isinstance(l, util.datetime_types):
xdate, ydate = isinstance(l, util.datetime_types), isinstance(b, util.datetime_types)
if l == r:
xlin = np.full((dim1,), l, dtype=('datetime64[us]' if xdate else 'float'))
elif xdate:
xlin = util.date_range(l, r, dim1, dataset._time_unit)
else:
xstep = float(r - l)/dim1
xlin = np.linspace(l+(xstep/2.), r-(xstep/2.), dim1)
if isinstance(b, util.datetime_types):
if b == t:
ylin = np.full((dim2,), b, dtype=('datetime64[us]' if ydate else 'float'))
elif ydate:
ylin = util.date_range(b, t, dim2, dataset._time_unit)
else:
ystep = float(t - b)/dim2
Expand Down
8 changes: 2 additions & 6 deletions holoviews/operation/datashader.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,19 @@ def _get_sampling(self, element, x, y):
xstart, xend = dt_to_int(xstart, 'ns'), dt_to_int(xend, 'ns')
xtype = 'datetime'
elif not np.isfinite(xstart) and not np.isfinite(xend):
xstart, xend = 0, 0
if element.get_dimension_type(x) in datetime_types:
xstart, xend = 0, 10000
xtype = 'datetime'
else:
xstart, xend = 0, 1
x_range = (xstart, xend)

ytype = 'numeric'
if isinstance(ystart, datetime_types) or isinstance(yend, datetime_types):
ystart, yend = dt_to_int(ystart, 'ns'), dt_to_int(yend, 'ns')
ytype = 'datetime'
elif not np.isfinite(ystart) and not np.isfinite(yend):
ystart, yend = 0, 0
if element.get_dimension_type(y) in datetime_types:
ystart, yend = 0, 10000
ytype = 'datetime'
else:
ystart, yend = 0, 1
y_range = (ystart, yend)

# Compute highest allowed sampling density
Expand Down

0 comments on commit 2fa1c0a

Please sign in to comment.