Skip to content

Commit

Permalink
Simplify logic
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Nov 2, 2023
1 parent 890da8a commit 279527d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions holoviews/element/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,18 +530,18 @@ class ImageStack(Image):
_vdim_reductions = {1: Image}

def __init__(self, data, kdims=None, vdims=None, **params):
_kdims = kdims or self.kdims
if isinstance(data, list) and len(data) > 0:
x = np.arange(data[0].shape[1])
y = np.arange(data[0].shape[0])
data_tuple = (x, y, *(d for d in data))
data_tuple = (x, y, *data)
elif isinstance(data, dict):
_kdims = kdims or self.kdims
first = next(v for k, v in data.items() if k not in _kdims)
# TODO: Make it work with dict which hv.Dimension key
x = data.get(str(_kdims[0]), np.arange(first.shape[1]))
y = data.get(str(_kdims[1]), np.arange(first.shape[0]))
iter_data = (v for k, v in data.items() if k not in _kdims)
data_tuple = (x, y, *(d for d in iter_data))
data_tuple = (x, y, *iter_data)
elif isinstance(data, np.ndarray) and data.ndim == 3:
x = np.arange(data.shape[1])
y = np.arange(data.shape[0])
Expand All @@ -557,7 +557,7 @@ def __init__(self, data, kdims=None, vdims=None, **params):
if isinstance(data_tuple, tuple):
vdims = [Dimension(f"level_{i}") for i in range(len(data_tuple[2:]))]
elif isinstance(data, dict):
vdims = [Dimension(key) for key in data.keys() if key not in (kdims or self.kdims)]
vdims = [Dimension(key) for key in data.keys() if key not in _kdims]
super().__init__(data_tuple, kdims=kdims, vdims=vdims, **params)


Expand Down

0 comments on commit 279527d

Please sign in to comment.