Skip to content

Commit

Permalink
Merge 5750276 into 9197137
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Mar 3, 2020
2 parents 9197137 + 5750276 commit f8eb813
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
7 changes: 5 additions & 2 deletions holoviews/operation/datashader.py
Expand Up @@ -810,9 +810,12 @@ def _get_xarrays(self, element, coords, xtype, ytype):
coord_dict = {x.name: coords[0], y.name: coords[1]}

arrays = {}
for vd in element.vdims:
for i, vd in enumerate(element.vdims):
if element.interface is XArrayInterface:
xarr = element.data[vd.name]
if element.interface.packed(element):
xarr = element.data[..., i]
else:
xarr = element.data[vd.name]
if 'datetime' in (xtype, ytype):
xarr = xarr.copy()
if dims != xarr.dims and not irregular:
Expand Down
30 changes: 30 additions & 0 deletions holoviews/tests/operation/testdatashader.py
Expand Up @@ -11,6 +11,7 @@
try:
import datashader as ds
import dask.dataframe as dd
import xarray as xr
from holoviews.core.util import pd
from holoviews.operation.datashader import (
aggregate, regrid, ds_version, stack, directly_connect_edges,
Expand Down Expand Up @@ -471,6 +472,35 @@ def test_spread_aggregate_assymmetric_count(self):
expected = Image((xs, ys, arr), vdims='count')
self.assertEqual(agg, expected)

def test_rgb_regrid_packed(self):
coords = {'x': [1, 2], 'y': [1, 2], 'band': [0, 1, 2]}
arr = np.array([
[[255, 10],
[ 0, 30]],
[[ 1, 0],
[ 0, 0]],
[[127, 0],
[ 0, 68]],
]).T
da = xr.DataArray(data=arr, dims=('x', 'y', 'band'), coords=coords)
im = RGB(da)
agg = rasterize(im, width=3, height=3, dynamic=False, upsample=True)
xs = [0.8333333, 1.5, 2.166666]
ys = [0.8333333, 1.5, 2.166666]
arr = np.array([
[[255, 255, 10],
[255, 255, 10],
[ 0, 0, 30]],
[[ 1, 1, 0],
[ 1, 1, 0],
[ 0, 0, 0]],
[[127, 127, 0],
[127, 127, 0],
[ 0, 0, 68]],
]).transpose((1, 2, 0))
expected = RGB((xs, ys, arr))
self.assertEqual(agg, expected)

@spatialpandas_skip
def test_line_rasterize(self):
path = Path([[(0, 0), (1, 1), (2, 0)], [(0, 0), (0, 1)]], datatype=['spatialpandas'])
Expand Down

0 comments on commit f8eb813

Please sign in to comment.