Skip to content

Commit

Permalink
Fix class variable not being used for vdims in RGB (#5773)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Jun 21, 2023
1 parent 1c30bf5 commit be58b7e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion holoviews/element/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
5 changes: 5 additions & 0 deletions holoviews/tests/element/test_raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down

0 comments on commit be58b7e

Please sign in to comment.