Fix conversion from cupy in categorical rescale_discrete_levels #1179
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See issue #1178.
When using
cudf
, a categorical aggregate,how='eq_hist'
andrescale_discrete_levels=True
then categorical shading raises an error when trying to convert a tuple that contains acupy
array and scalar to acupy
array.The simplest possible fix would have been in
_rescale_discrete_levels()
here:datashader/datashader/transfer_functions/__init__.py
Lines 230 to 232 in d8167b4
by casting
lower_span
to afloat
. This is fine iflower_span
ia a scalar ornumpy
array, but if it is acupy
array then this would transfer it from GPU to CPU memory, only to be pushed back to the GPU subsequently. The solution here is to convert the span from tuple tonumpy
/cupy
array usinghstack
in_interpolate_alpha
.This fixes the error produced by the OP's example code, but there is still a problem in
holoviews
not displaying the categorical legend if using the GPU. I will create a separateholoviews
issue for this.