Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
z_index = z_index or 0
if len(data) > 0:
if np.array(data[0]).ndim == 1:
# If a single array for a shape has been passed turn into list
data = [data]
# Turn input arguments into iterables
shape_inputs = zip(
data,
ensure_iterable(shape_type),
ensure_iterable(edge_width),
ensure_iterable(edge_color, color=True),
ensure_iterable(face_color, color=True),
ensure_iterable(opacity),
ensure_iterable(z_index),
)
for d, st, ew, ec, fc, o, z in shape_inputs:
# A False slice_key means the shape is invalid as it is not
# confined to a single plane
shape_cls = shape_classes[ShapeType(st)]
shape = shape_cls(
d,
edge_width=ew,
edge_color=ec,
face_color=fc,
opacity=o,
z_index=z,
dims_order=self.dims.order,
ndisplay=self.dims.ndisplay,
else:
z_index = z_index or 0
if len(data) > 0:
if np.array(data[0]).ndim == 1:
# If a single array for a shape has been passed turn into list
data = [data]
# Turn input arguments into iterables
shape_inputs = zip(
data,
ensure_iterable(shape_type),
ensure_iterable(edge_width),
ensure_iterable(edge_color, color=True),
ensure_iterable(face_color, color=True),
ensure_iterable(opacity),
ensure_iterable(z_index),
)
for d, st, ew, ec, fc, o, z in shape_inputs:
# A False slice_key means the shape is invalid as it is not
# confined to a single plane
shape_cls = shape_classes[ShapeType(st)]
shape = shape_cls(
d,
edge_width=ew,
edge_color=ec,
face_color=fc,
opacity=o,
z_index=z,
dims_order=self.dims.order,
if self._data_view is not None:
z_index = z_index or max(self._data_view._z_index, default=-1) + 1
else:
z_index = z_index or 0
if len(data) > 0:
if np.array(data[0]).ndim == 1:
# If a single array for a shape has been passed turn into list
data = [data]
# Turn input arguments into iterables
shape_inputs = zip(
data,
ensure_iterable(shape_type),
ensure_iterable(edge_width),
ensure_iterable(edge_color, color=True),
ensure_iterable(face_color, color=True),
ensure_iterable(opacity),
ensure_iterable(z_index),
)
for d, st, ew, ec, fc, o, z in shape_inputs:
# A False slice_key means the shape is invalid as it is not
# confined to a single plane
shape_cls = shape_classes[ShapeType(st)]
shape = shape_cls(
d,
edge_width=ew,
edge_color=ec,
face_color=fc,
opacity=o,
# Full data indices of points located in the currently viewed slice
self._indices_view = []
self._drag_box = None
self._drag_box_stored = None
self._is_selecting = False
self._clipboard = {}
self.edge_colors = list(
itertools.islice(
ensure_iterable(edge_color, color=True), 0, len(self.data)
)
)
self.face_colors = list(
itertools.islice(
ensure_iterable(face_color, color=True), 0, len(self.data)
)
)
self.sizes = size
# Trigger generation of view slice and thumbnail
self._update_dims()
n_channels = data[0].shape[channel_axis]
else:
n_channels = data.shape[channel_axis]
name = ensure_iterable(name)
if blending is None:
blending = 'additive'
if colormap is None:
if n_channels < 3:
colormap = colormaps.MAGENTA_GREEN
else:
colormap = itertools.cycle(colormaps.CYMRGB)
else:
colormap = ensure_iterable(colormap)
# If one pair of clim values is passed then need to iterate them to
# all layers.
if contrast_limits is not None and not is_iterable(
contrast_limits[0]
):
contrast_limits = itertools.repeat(contrast_limits)
else:
contrast_limits = ensure_iterable(contrast_limits)
gamma = ensure_iterable(gamma)
layer_list = []
zipped_args = zip(
range(n_channels), colormap, contrast_limits, gamma, name
)
z_index = z_index or max(self._data_view._z_index, default=-1) + 1
else:
z_index = z_index or 0
if len(data) > 0:
if np.array(data[0]).ndim == 1:
# If a single array for a shape has been passed turn into list
data = [data]
# Turn input arguments into iterables
shape_inputs = zip(
data,
ensure_iterable(shape_type),
ensure_iterable(edge_width),
ensure_iterable(edge_color, color=True),
ensure_iterable(face_color, color=True),
ensure_iterable(opacity),
ensure_iterable(z_index),
)
for d, st, ew, ec, fc, o, z in shape_inputs:
# A False slice_key means the shape is invalid as it is not
# confined to a single plane
shape_cls = shape_classes[ShapeType(st)]
shape = shape_cls(
d,
edge_width=ew,
edge_color=ec,
face_color=fc,
opacity=o,
z_index=z,
opacity = self.opacity
if self._data_view is not None:
z_index = z_index or max(self._data_view._z_index, default=-1) + 1
else:
z_index = z_index or 0
if len(data) > 0:
if np.array(data[0]).ndim == 1:
# If a single array for a shape has been passed turn into list
data = [data]
# Turn input arguments into iterables
shape_inputs = zip(
data,
ensure_iterable(shape_type),
ensure_iterable(edge_width),
ensure_iterable(edge_color, color=True),
ensure_iterable(face_color, color=True),
ensure_iterable(opacity),
ensure_iterable(z_index),
)
for d, st, ew, ec, fc, o, z in shape_inputs:
# A False slice_key means the shape is invalid as it is not
# confined to a single plane
shape_cls = shape_classes[ShapeType(st)]
shape = shape_cls(
d,
edge_width=ew,
edge_color=ec,
face_color=fc,