Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix class variable not being used for vdims in RGB #5773

Merged
merged 1 commit into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
hoxbro marked this conversation as resolved.
Show resolved Hide resolved
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):
hoxbro marked this conversation as resolved.
Show resolved Hide resolved
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