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

Fix dask TriMesh rasterization #4935

Merged
merged 4 commits into from
May 18, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions holoviews/operation/datashader.py
Original file line number Diff line number Diff line change
Expand Up @@ -987,16 +987,31 @@ class trimesh_rasterize(aggregate):
def _precompute(self, element, agg):
from datashader.utils import mesh
if element.vdims and getattr(agg, 'column', None) not in element.nodes.vdims:
simplices = element.dframe([0, 1, 2, 3])
verts = element.nodes.dframe([0, 1])
simplex_dims = [0, 1, 2, 3]
vert_dims = [0, 1]
elif element.nodes.vdims:
simplices = element.dframe([0, 1, 2])
verts = element.nodes.dframe([0, 1, 3])
simplex_dims = [0, 1, 2]
vert_dims = [0, 1, 3]
else:
raise ValueError("Cannot shade TriMesh without value dimension.")
if set([element.interface.datatype, element.nodes.interface.datatype]) == {'dask'}:
dims, node_dims = element.dimensions(), element.nodes.dimensions()
simplices = element.data[[dims[sd].name for sd in simplex_dims]]
verts = element.nodes.data[[node_dims[vd].name for vd in vert_dims]]
else:
philippjfr marked this conversation as resolved.
Show resolved Hide resolved
simplices = element.dframe(simplex_dims)
verts = element.nodes.dframe(vert_dims)
for c, dtype in zip(simplices.columns[:3], simplices.dtypes):
if dtype.kind != 'i':
simplices[c] = simplices[c].astype('int')
return {'mesh': mesh(verts, simplices), 'simplices': simplices,
'vertices': verts}
mesh = mesh(verts, simplices)
if hasattr(mesh, 'persist'):
mesh = mesh.persist()
return {
'mesh': mesh,
'simplices': simplices,
'vertices': verts
}

def _precompute_wireframe(self, element, agg):
if hasattr(element, '_wireframe'):
Expand Down Expand Up @@ -1037,7 +1052,6 @@ def _process(self, element, key=None):
precomputed = self._precompute_wireframe(element, agg)
else:
precomputed = self._precompute(element, agg)

bounds = (x_range[0], y_range[0], x_range[1], y_range[1])
params = self._get_agg_params(element, x, y, agg, bounds)

Expand Down