diff --git a/holoviews/tests/operation/test_datashader.py b/holoviews/tests/operation/test_datashader.py index 8c6c1c185a..45c5f43c85 100644 --- a/holoviews/tests/operation/test_datashader.py +++ b/holoviews/tests/operation/test_datashader.py @@ -1,4 +1,5 @@ import datetime as dt +from contextlib import suppress from unittest import SkipTest, skipIf import colorcet as cc @@ -1410,6 +1411,26 @@ def test_datashade_selector(point_plot, sel_fn): np.testing.assert_array_equal(img[n], img_count[n], err_msg=n) +@pytest.mark.parametrize("op_fn", (rasterize, datashade)) +def test_spread_selector(point_plot, op_fn): + inputs = dict(dynamic=False, x_range=(-1, 1), y_range=(-1, 1), width=10, height=10) + img = op_fn(point_plot, selector=ds.first("val"), **inputs) + spread_img = spread(img) + + with suppress(AssertionError): # We expect them to be different + xr.testing.assert_equal(spread_img.data, img.data) + raise ValueError("The spread should not be equal to the original image") + + with suppress(AssertionError): # We expect them to be different + np.testing.assert_array_equal(spread_img.data["__index__"], img.data["__index__"]) + raise ValueError("The spread should not be equal to the original image") + + vdim = spread_img.vdims[-1].name # Last one as it is alpha for datashade + vdim_nan = spread_img.data[vdim] == 0 + index_nan = spread_img.data["__index__"] == -1 + np.testing.assert_array_equal(vdim_nan, index_nan) + + def test_rasterize_with_datetime_column(): n = 4 df = pd.DataFrame({