From 394c87380c39d12374f407978d1c751f77f07f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Tue, 5 Nov 2024 10:56:46 +0100 Subject: [PATCH] dont overwrite existing data in dynspread with selector --- holoviews/operation/datashader.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/holoviews/operation/datashader.py b/holoviews/operation/datashader.py index d0886cf845..e76f4a1146 100644 --- a/holoviews/operation/datashader.py +++ b/holoviews/operation/datashader.py @@ -1691,29 +1691,34 @@ def _process(self, element, key=None): array = self._apply_spreading(data) if "selector_columns" in getattr(element.data, "attrs", ()): - index = element.data["__index__"].copy() + new_data = element.data.copy() + index = new_data["__index__"].copy() mask = np.arange(index.size).reshape(index.shape) mask[index == -1] = 0 index.data = mask spread_index = self._apply_spreading(index, how="source") sel_data = { - sc: element.data[sc].data.ravel()[spread_index].reshape(index.shape) - for sc in element.data.attrs["selector_columns"] + sc: new_data[sc].data.ravel()[spread_index].reshape(index.shape) + for sc in new_data.attrs["selector_columns"] } - element = element.clone() if isinstance(element, RGB): img = datashade.uint32_to_uint8(array.data)[::-1] for idx, k, in enumerate("RGBA"): - element.data[k].data = img[:, :, idx] + new_data[k].data = img[:, :, idx] elif isinstance(element, Image): - element.data[element.vdims[0].name].data = array + new_data[element.vdims[0].name].data = array else: msg = "ImageStack currently does not support spreading with selector_columns" raise NotImplementedError(msg) for k, v in sel_data.items(): - element.data[k].data = v + new_data[k].data = v + + # TODO: Investigate why this does not work + # element = element.clone(data=new_data, kdims=element.vdims.copy(), vdims=element.vdims.copy()) + element = element.clone() + element.data = new_data return element kwargs = {}