From be58b7e13dc54ce68b1f98460f592a326f7c0529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Wed, 21 Jun 2023 18:12:53 +0200 Subject: [PATCH] Fix class variable not being used for vdims in RGB (#5773) --- holoviews/element/raster.py | 3 ++- holoviews/tests/element/test_raster.py | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/holoviews/element/raster.py b/holoviews/element/raster.py index da1acf2f84..ba51d3c83f 100644 --- a/holoviews/element/raster.py +++ b/holoviews/element/raster.py @@ -610,7 +610,8 @@ def __init__(self, data, kdims=None, vdims=None, **params): arrays = [(im.data - r[0]) / (r[1] - r[0]) for r,im in zip(ranges, images)] data = np.dstack(arrays) if vdims is None: - vdims = list(self.vdims) + # Same as the class variables, put here to secure the class variable is not used + vdims = [Dimension(c, range=(0,1)) for c in "RGB"] else: vdims = list(vdims) if isinstance(vdims, list) else [vdims] diff --git a/holoviews/tests/element/test_raster.py b/holoviews/tests/element/test_raster.py index aa47f66329..0955b61566 100644 --- a/holoviews/tests/element/test_raster.py +++ b/holoviews/tests/element/test_raster.py @@ -48,6 +48,11 @@ def test_construct_from_dict_with_alpha(self): rgb = RGB({'x': [1, 2, 3], 'y': [1, 2, 3], ('R', 'G', 'B', 'A'): self.rgb_array}) self.assertEqual(len(rgb.vdims), 4) + def test_not_using_class_variables_vdims(self): + init_vdims = RGB(self.rgb_array).vdims + cls_vdims = RGB.vdims + for i, c in zip(init_vdims, cls_vdims): + assert i is not c class TestQuadMesh(ComparisonTestCase):