Repository: holoviz/holoviews (python)

Issue:
Dask DataFrame + Lasso select linked brushing not working
IMPORTANT: I have narrowed down the problem to the following line of code. Assignment like this is not supported by Dask. I will submit an accompanying pull request with a proposed fix.
https://github.com/holoviz/holoviews/blob/f7017e3012ef60d7368676d1c87efe8194d03a1e/holoviews/element/selection.py#L120 

#### ALL software version info
python=3.10.8
bokeh=2.4.3
dask=2022.12.0
datashader=0.14.3
holoviews=1.15.3
numpy=1.23.5
pandas=1.5.2
panel=0.14.1
spatialpandas=0.4.5

#### Description of expected behavior and the observed behavior
Attempting to lasso-select points that are backed by a Dask DataFrame results in an error. Box select works fine, but lasso select does not. This issue exists for both datashaded and non-datshaded plots. Same result using spatialpandas and shapely.

#### Complete, minimal, self-contained example code that reproduces the issue

```python
import dask.dataframe as dd
import holoviews as hv
import panel as pn
from holoviews.operation.datashader import datashade
from numpy.random import randn


hv.extension("bokeh")

df = dd.from_dict({"x": randn(1000), "y": randn(1000)}, npartitions=2)

link = hv.link_selections.instance()

non_datashaded_plot = link(hv.Points(df))
datashaded_plot = link(datashade(hv.Points(df)))
pn.Column(non_datashaded_plot + datashaded_plot).show()

# Error will occur when you try to lasso-select data in either plot
```

#### Stack traceback and/or browser JavaScript console output
```shell
WARNING:param.dynamic_operation: Callable raised "CallbackError('linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.')".
Invoked as dynamic_operation(cmap=None, exprs=[True, dim('x', spatial_select, dim('y'), geometry=array([[ 1.81901611,  0.02067943],
       [ 1.9212558 ,  0.3637043 ],
       [ 1.853096  ,  0.70672917],
       [ 1.27373776,  0.73791325],
       [-0.70289623,  0.64436101],
       [-2.23649157,  0.33252022],
       [-2.88400961, -0.04168873],
       [-3.25888847, -0.66537031],
       [-3.49744774, -1.66326085],
       [-3.39520805, -2.50523099],
       [-2.9862493 , -3.12891257],
       [-2.54321064, -3.5343056 ],
       [-1.92977251, -3.690226  ],
       [-1.45265396, -3.72141008],
       [-1.14593489, -3.72141008],
       [-1.0096153 , -3.690226  ],
       [-0.80513592, -3.65904192],
       [-0.77105603, -3.62785784],
       [-0.77105603, -3.62785784]]))])
WARNING:param.dynamic_operation: Callable raised "CallbackError('linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.')".
Invoked as dynamic_operation(alpha=0.1, colors=[None, None], cmap=None)
WARNING:param.dynamic_operation: Callable raised "CallbackError('linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.')".
Invoked as dynamic_operation(cmap=None, exprs=[True, dim('x', spatial_select, dim('y'), geometry=array([[ 1.81901611,  0.02067943],
       [ 1.9212558 ,  0.3637043 ],
       [ 1.853096  ,  0.70672917],
       [ 1.27373776,  0.73791325],
       [-0.70289623,  0.64436101],
       [-2.23649157,  0.33252022],
       [-2.88400961, -0.04168873],
       [-3.25888847, -0.66537031],
       [-3.49744774, -1.66326085],
       [-3.39520805, -2.50523099],
       [-2.9862493 , -3.12891257],
       [-2.54321064, -3.5343056 ],
       [-1.92977251, -3.690226  ],
       [-1.45265396, -3.72141008],
       [-1.14593489, -3.72141008],
       [-1.0096153 , -3.690226  ],
       [-0.80513592, -3.65904192],
       [-0.77105603, -3.62785784],
       [-0.77105603, -3.62785784]]))])
WARNING:param.dynamic_operation: Callable raised "CallbackError('linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.')".
Invoked as dynamic_operation(alpha=0.1, colors=[None, None], cmap=None)
WARNING:param.dynamic_operation: Callable raised "CallbackError('linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.')".
Invoked as dynamic_operation(cmap=None, exprs=[True, dim('x', spatial_select, dim('y'), geometry=array([[ 1.81901611,  0.02067943],
       [ 1.9212558 ,  0.3637043 ],
       [ 1.853096  ,  0.70672917],
       [ 1.27373776,  0.73791325],
       [-0.70289623,  0.64436101],
       [-2.23649157,  0.33252022],
       [-2.88400961, -0.04168873],
       [-3.25888847, -0.66537031],
       [-3.49744774, -1.66326085],
       [-3.39520805, -2.50523099],
       [-2.9862493 , -3.12891257],
       [-2.54321064, -3.5343056 ],
       [-1.92977251, -3.690226  ],
       [-1.45265396, -3.72141008],
       [-1.14593489, -3.72141008],
       [-1.0096153 , -3.690226  ],
       [-0.80513592, -3.65904192],
       [-0.77105603, -3.62785784],
       [-0.77105603, -3.62785784]]))])
WARNING:param.dynamic_operation: Callable raised "CallbackError('linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.')".
Invoked as dynamic_operation(alpha=0.1, colors=[None, None], cmap=None)
Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7fb2d03e7610>>, <Task finished name='Task-1101' coro=<ServerSession.with_document_locked() done, defined at /user_environment/lib/python3.10/site-packages/bokeh/server/session.py:78> exception=CallbackError('linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.')>)
Traceback (most recent call last):
  File "/user_environment/lib/python3.10/site-packages/holoviews/selection.py", line 511, in _select
    mask = selection_expr.apply(dataset, compute=False, keep_index=True, strict=False)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/transform.py", line 773, in apply
    data = self._apply_fn(dataset, data, fn, fn_name, args,
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/transform.py", line 673, in _apply_fn
    data = fn(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/element/selection.py", line 128, in spatial_select
    return spatial_select_columnar(xvals, yvals, geometry)
  File "/user_environment/lib/python3.10/site-packages/holoviews/element/selection.py", line 120, in spatial_select_columnar
    mask[np.where(mask)[0]] = geom_mask
TypeError: only integer scalar arrays can be converted to a scalar index

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/user_environment/lib/python3.10/site-packages/tornado/ioloop.py", line 740, in _run_callback
    ret = callback()
  File "/user_environment/lib/python3.10/site-packages/tornado/ioloop.py", line 764, in _discard_future_result
    future.result()
  File "/user_environment/lib/python3.10/site-packages/bokeh/server/session.py", line 95, in _needs_document_lock_wrapper
    result = func(self, *args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/bokeh/server/session.py", line 229, in with_document_locked
    return func(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 450, in wrapper
    return invoke_with_curdoc(doc, invoke)
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 408, in invoke_with_curdoc
    return f()
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 449, in invoke
    return f(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 179, in remove_then_invoke
    return callback()
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 243, in refresh
    raise e
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 239, in refresh
    self._trigger_refresh(stream_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 256, in _trigger_refresh
    self.update(key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 949, in update
    item = self.__getitem__(key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 435, in __getitem__
    self.update_frame(frame)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/bokeh/element.py", line 2410, in update_frame
    element = self._get_frame(key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 1259, in _get_frame
    frame = get_plot_frame(self.hmap, key_map, cached)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/util.py", line 284, in get_plot_frame
    raise e
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/util.py", line 280, in get_plot_frame
    return map_obj[key]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 550, in __call__
    if not args and not kwargs and not any(kwarg_hash): return self.callable()
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 199, in dynamic_mul
    self_el = self.select(HoloMap, **key_map) if self.kdims else self[()]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 550, in __call__
    if not args and not kwargs and not any(kwarg_hash): return self.callable()
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 204, in dynamic_mul
    other_el = other.select(HoloMap, **key_map) if other.kdims else other[()]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 581, in __call__
    ret = self.callable(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1012, in dynamic_operation
    key, obj = resolve(key, kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1001, in resolve
    return key, map_obj[key]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 581, in __call__
    ret = self.callable(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1013, in dynamic_operation
    return apply(obj, *key, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1005, in apply
    processed = self._process(element, key, kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 989, in _process
    return self.p.operation(element, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/selection.py", line 612, in _build_layer_callback
    selection = self._select(element, exprs[layer_number], cache)
  File "/user_environment/lib/python3.10/site-packages/holoviews/selection.py", line 519, in _select
    raise CallbackError("linked_selection aborted because it could not "
holoviews.core.options.CallbackError: linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.
Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7fb2d03e7610>>, <Task finished name='Task-1102' coro=<ServerSession.with_document_locked() done, defined at /user_environment/lib/python3.10/site-packages/bokeh/server/session.py:78> exception=CallbackError('linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.')>)
Traceback (most recent call last):
  File "/user_environment/lib/python3.10/site-packages/holoviews/selection.py", line 511, in _select
    mask = selection_expr.apply(dataset, compute=False, keep_index=True, strict=False)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/transform.py", line 773, in apply
    data = self._apply_fn(dataset, data, fn, fn_name, args,
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/transform.py", line 673, in _apply_fn
    data = fn(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/element/selection.py", line 128, in spatial_select
    return spatial_select_columnar(xvals, yvals, geometry)
  File "/user_environment/lib/python3.10/site-packages/holoviews/element/selection.py", line 120, in spatial_select_columnar
    mask[np.where(mask)[0]] = geom_mask
TypeError: only integer scalar arrays can be converted to a scalar index

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/user_environment/lib/python3.10/site-packages/tornado/ioloop.py", line 740, in _run_callback
    ret = callback()
  File "/user_environment/lib/python3.10/site-packages/tornado/ioloop.py", line 764, in _discard_future_result
    future.result()
  File "/user_environment/lib/python3.10/site-packages/bokeh/server/session.py", line 95, in _needs_document_lock_wrapper
    result = func(self, *args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/bokeh/server/session.py", line 229, in with_document_locked
    return func(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 450, in wrapper
    return invoke_with_curdoc(doc, invoke)
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 408, in invoke_with_curdoc
    return f()
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 449, in invoke
    return f(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 179, in remove_then_invoke
    return callback()
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 243, in refresh
    raise e
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 239, in refresh
    self._trigger_refresh(stream_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 256, in _trigger_refresh
    self.update(key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 949, in update
    item = self.__getitem__(key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 435, in __getitem__
    self.update_frame(frame)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/bokeh/element.py", line 2410, in update_frame
    element = self._get_frame(key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 1259, in _get_frame
    frame = get_plot_frame(self.hmap, key_map, cached)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/util.py", line 284, in get_plot_frame
    raise e
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/util.py", line 280, in get_plot_frame
    return map_obj[key]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 550, in __call__
    if not args and not kwargs and not any(kwarg_hash): return self.callable()
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 199, in dynamic_mul
    self_el = self.select(HoloMap, **key_map) if self.kdims else self[()]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 550, in __call__
    if not args and not kwargs and not any(kwarg_hash): return self.callable()
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 204, in dynamic_mul
    other_el = other.select(HoloMap, **key_map) if other.kdims else other[()]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 581, in __call__
    ret = self.callable(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1012, in dynamic_operation
    key, obj = resolve(key, kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1001, in resolve
    return key, map_obj[key]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 581, in __call__
    ret = self.callable(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1013, in dynamic_operation
    return apply(obj, *key, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1005, in apply
    processed = self._process(element, key, kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 989, in _process
    return self.p.operation(element, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/selection.py", line 612, in _build_layer_callback
    selection = self._select(element, exprs[layer_number], cache)
  File "/user_environment/lib/python3.10/site-packages/holoviews/selection.py", line 519, in _select
    raise CallbackError("linked_selection aborted because it could not "
holoviews.core.options.CallbackError: linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.
Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x7fb2d03e7610>>, <Task finished name='Task-1104' coro=<ServerSession.with_document_locked() done, defined at /user_environment/lib/python3.10/site-packages/bokeh/server/session.py:78> exception=CallbackError('linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.')>)
Traceback (most recent call last):
  File "/user_environment/lib/python3.10/site-packages/holoviews/selection.py", line 511, in _select
    mask = selection_expr.apply(dataset, compute=False, keep_index=True, strict=False)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/transform.py", line 773, in apply
    data = self._apply_fn(dataset, data, fn, fn_name, args,
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/transform.py", line 673, in _apply_fn
    data = fn(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/element/selection.py", line 128, in spatial_select
    return spatial_select_columnar(xvals, yvals, geometry)
  File "/user_environment/lib/python3.10/site-packages/holoviews/element/selection.py", line 120, in spatial_select_columnar
    mask[np.where(mask)[0]] = geom_mask
TypeError: only integer scalar arrays can be converted to a scalar index

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/user_environment/lib/python3.10/site-packages/tornado/ioloop.py", line 740, in _run_callback
    ret = callback()
  File "/user_environment/lib/python3.10/site-packages/tornado/ioloop.py", line 764, in _discard_future_result
    future.result()
  File "/user_environment/lib/python3.10/site-packages/bokeh/server/session.py", line 95, in _needs_document_lock_wrapper
    result = func(self, *args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/bokeh/server/session.py", line 229, in with_document_locked
    return func(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 450, in wrapper
    return invoke_with_curdoc(doc, invoke)
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 408, in invoke_with_curdoc
    return f()
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 449, in invoke
    return f(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/bokeh/document/callbacks.py", line 179, in remove_then_invoke
    return callback()
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 243, in refresh
    raise e
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 239, in refresh
    self._trigger_refresh(stream_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 256, in _trigger_refresh
    self.update(key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 949, in update
    item = self.__getitem__(key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 435, in __getitem__
    self.update_frame(frame)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/bokeh/element.py", line 2410, in update_frame
    element = self._get_frame(key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/plot.py", line 1259, in _get_frame
    frame = get_plot_frame(self.hmap, key_map, cached)
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/util.py", line 284, in get_plot_frame
    raise e
  File "/user_environment/lib/python3.10/site-packages/holoviews/plotting/util.py", line 280, in get_plot_frame
    return map_obj[key]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 550, in __call__
    if not args and not kwargs and not any(kwarg_hash): return self.callable()
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 199, in dynamic_mul
    self_el = self.select(HoloMap, **key_map) if self.kdims else self[()]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 550, in __call__
    if not args and not kwargs and not any(kwarg_hash): return self.callable()
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 204, in dynamic_mul
    other_el = other.select(HoloMap, **key_map) if other.kdims else other[()]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 581, in __call__
    ret = self.callable(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1012, in dynamic_operation
    key, obj = resolve(key, kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1001, in resolve
    return key, map_obj[key]
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 1216, in __getitem__
    val = self._execute_callback(*tuple_key)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 983, in _execute_callback
    retval = self.callback(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/core/spaces.py", line 581, in __call__
    ret = self.callable(*args, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1013, in dynamic_operation
    return apply(obj, *key, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 1005, in apply
    processed = self._process(element, key, kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/util/__init__.py", line 989, in _process
    return self.p.operation(element, **kwargs)
  File "/user_environment/lib/python3.10/site-packages/holoviews/selection.py", line 612, in _build_layer_callback
    selection = self._select(element, exprs[layer_number], cache)
  File "/user_environment/lib/python3.10/site-packages/holoviews/selection.py", line 519, in _select
    raise CallbackError("linked_selection aborted because it could not "
holoviews.core.options.CallbackError: linked_selection aborted because it could not display selection for all elements: only integer scalar arrays can be converted to a scalar index.
```

Pull request description:
During lasso select, mask values using Dask-compatible method
Fixes #5567.

Dask is not compatible with direct assignment when using an array of indices. This change catches the `TypeError` raised when direct assignment is attempted on a Dask Series, and reverts to using the mask() method of `dask.Series`.

Patch:
diff --git a/holoviews/element/selection.py b/holoviews/element/selection.py
index 05a4365e3..a8011d4cb 100644
--- a/holoviews/element/selection.py
+++ b/holoviews/element/selection.py
@@ -6,6 +6,7 @@ elements.
 import sys
 
 import numpy as np
+import pandas as pd
 
 from ..core import Dataset, NdOverlay, util
 from ..streams import SelectionXY, Selection1D, Lasso
@@ -72,11 +73,11 @@ def spatial_select_gridded(xvals, yvals, geometry):
         xs, ys = xvals[0], yvals[:, 0]
         target = Image((xs, ys, np.empty(ys.shape+xs.shape)))
         poly = Polygons([geometry])
-        mask = rasterize(poly, target=target, dynamic=False, aggregator='any')
-        return mask.dimension_values(2, flat=False)
+        sel_mask = rasterize(poly, target=target, dynamic=False, aggregator='any')
+        return sel_mask.dimension_values(2, flat=False)
     else:
-        mask = spatial_select_columnar(xvals.flatten(), yvals.flatten(), geometry)
-        return mask.reshape(xvals.shape)
+        sel_mask = spatial_select_columnar(xvals.flatten(), yvals.flatten(), geometry)
+        return sel_mask.reshape(xvals.shape)
 
 def spatial_select_columnar(xvals, yvals, geometry):
     if 'cudf' in sys.modules:
@@ -98,11 +99,26 @@ def spatial_select_columnar(xvals, yvals, geometry):
             except Exception:
                 xvals = np.asarray(xvals)
                 yvals = np.asarray(yvals)
+    if 'dask' in sys.modules:
+        import dask.dataframe as dd
+        if isinstance(xvals, dd.Series):
+            try:
+                xvals.name = "xvals"
+                yvals.name = "yvals"
+                df = xvals.to_frame().join(yvals)
+                return df.map_partitions(
+                    lambda df, geometry: spatial_select_columnar(df.xvals, df.yvals, geometry),
+                    geometry,
+                    meta=pd.Series(dtype=bool)
+                )
+            except Exception:
+                xvals = np.asarray(xvals)
+                yvals = np.asarray(yvals)
     x0, x1 = geometry[:, 0].min(), geometry[:, 0].max()
     y0, y1 = geometry[:, 1].min(), geometry[:, 1].max()
-    mask = (xvals>=x0) & (xvals<=x1) & (yvals>=y0) & (yvals<=y1)
-    masked_xvals = xvals[mask]
-    masked_yvals = yvals[mask]
+    sel_mask = (xvals>=x0) & (xvals<=x1) & (yvals>=y0) & (yvals<=y1)
+    masked_xvals = xvals[sel_mask]
+    masked_yvals = yvals[sel_mask]
     try:
         from spatialpandas.geometry import Polygon, PointArray
         points = PointArray((masked_xvals.astype('float'), masked_yvals.astype('float')))
@@ -117,8 +133,11 @@ def spatial_select_columnar(xvals, yvals, geometry):
         except ImportError:
             raise ImportError("Lasso selection on tabular data requires "
                               "either spatialpandas or shapely to be available.")
-    mask[np.where(mask)[0]] = geom_mask
-    return mask
+    if isinstance(xvals, pd.Series):
+        sel_mask[sel_mask.index[np.where(sel_mask)[0]]] = geom_mask
+    else:
+        sel_mask[np.where(sel_mask)[0]] = geom_mask
+    return sel_mask
 
 
 def spatial_select(xvals, yvals, geometry):
diff --git a/holoviews/util/_exception.py b/holoviews/util/_exception.py
index 1b312debf..ba64df18e 100644
--- a/holoviews/util/_exception.py
+++ b/holoviews/util/_exception.py
@@ -18,7 +18,7 @@ def deprecation_warning(msg, warning=FutureWarning):
     param_dir = os.path.dirname(param.__file__)
 
     frame = inspect.currentframe()
-    stacklevel = 1
+    stacklevel = 0
     while frame:
         fname = inspect.getfile(frame)
         if (fname.startswith(pkg_dir) or fname.startswith(param_dir)) and not fname.startswith(test_dir):


Test patch:
diff --git a/holoviews/tests/element/test_selection.py b/holoviews/tests/element/test_selection.py
index a6b844596..c2242e776 100644
--- a/holoviews/tests/element/test_selection.py
+++ b/holoviews/tests/element/test_selection.py
@@ -5,6 +5,8 @@ Test cases for the Comparisons class over the Chart elements
 from unittest import skipIf
 
 import numpy as np
+import pandas as pd
+import pytest
 
 from holoviews.core import NdOverlay
 from holoviews.core.options import Store
@@ -14,6 +16,7 @@ from holoviews.element import (
     QuadMesh, Polygons
 )
 from holoviews.element.comparison import ComparisonTestCase
+from holoviews.element.selection import spatial_select_columnar
 
 try:
     import datashader as ds
@@ -30,11 +33,17 @@ try:
 except:
     shapely = None
 
+try:
+    import dask.dataframe as dd
+except:
+    dd = None
+
 spd_available = skipIf(spd is None, "spatialpandas is not available")
 shapelib_available = skipIf(shapely is None and spd is None,
                             'Neither shapely nor spatialpandas are available')
 shapely_available = skipIf(shapely is None, 'shapely is not available')
 ds_available = skipIf(ds is None, 'datashader not available')
+dd_available = pytest.mark.skipif(dd is None, reason='dask.dataframe not available')
 
 
 class TestSelection1DExpr(ComparisonTestCase):
@@ -592,3 +601,71 @@ class TestSelectionPolyExpr(ComparisonTestCase):
                                 'x': np.array([-0.15, 0, 0.6, 0.6])})
         self.assertEqual(expr.apply(poly, expanded=False), np.array([False, False, True]))
         self.assertEqual(region, Rectangles([]) * Path([list(geom)+[(0.2, -0.15)]]))
+
+
+@shapelib_available
+class TestSpatialSelectColumnar:
+    geometry_encl = np.array([
+        [-1, 0.5],
+        [ 1, 0.5],
+        [ 0,-1.5],
+        [-2,-1.5]
+    ], dtype=float)
+
+    pt_mask_encl = np.array([
+        0, 0, 0,
+        1, 1, 0,
+        1, 1, 0,
+    ], dtype=bool)
+
+    geometry_noencl = np.array([
+        [10, 10],
+        [10, 11],
+        [11, 11],
+        [11, 10]
+    ], dtype=float)
+
+    pt_mask_noencl = np.array([
+        0, 0, 0,
+        0, 0, 0,
+        0, 0, 0,
+    ], dtype=bool)
+
+    @pytest.fixture(scope="module")
+    def pandas_df(self):
+        return pd.DataFrame({
+            "x": [-1, 0, 1,
+                  -1, 0, 1,
+                  -1, 0, 1],
+            "y": [ 1, 1, 1,
+                   0, 0, 0,
+                  -1,-1,-1]
+        }, dtype=float)
+
+    @dd_available
+    @pytest.fixture(scope="function")
+    def dask_df(self, pandas_df):
+        return dd.from_pandas(pandas_df, npartitions=2)
+
+    @pytest.mark.parametrize("geometry,pt_mask", [(geometry_encl, pt_mask_encl),(geometry_noencl, pt_mask_noencl)])
+    class TestSpatialSelectColumnarPtMask:
+        def test_pandas(self, geometry, pt_mask, pandas_df):
+            mask = spatial_select_columnar(pandas_df.x, pandas_df.y, geometry)
+            assert np.array_equal(mask, pt_mask)
+
+        @dd_available
+        def test_dask(self, geometry, pt_mask, dask_df):
+            mask = spatial_select_columnar(dask_df.x, dask_df.y, geometry)
+            assert np.array_equal(mask.compute(), pt_mask)
+
+        def test_numpy(self, geometry, pt_mask, pandas_df):
+            mask = spatial_select_columnar(pandas_df.x.to_numpy(copy=True), pandas_df.y.to_numpy(copy=True), geometry)
+            assert np.array_equal(mask, pt_mask)
+
+
+    @pytest.mark.parametrize("geometry", [geometry_encl, geometry_noencl])
+    class TestSpatialSelectColumnarDaskMeta:
+        @dd_available
+        def test_meta_dtype(self, geometry, dask_df):
+            mask = spatial_select_columnar(dask_df.x, dask_df.y, geometry)
+            assert mask._meta.dtype == np.bool_