# Buggy code
def __init__(self, layer, node):
    super().__init__()

    self.layer = layer
    self.node = node
    self._position = (0,) * self.layer.ndim
    self.camera = None

    self.layer.events.refresh.connect(lambda e: self.node.update())
    self.layer.events.set_data.connect(lambda e: self._on_data_change())

    self.layer.events.visible.connect(lambda e: self._on_visible_change())
    self.layer.events.opacity.connect(lambda e: self._on_opacity_change())
    self.layer.events.blending.connect(lambda e: self._on_blending_change())
    self.layer.events.scale.connect(lambda e: self._on_scale_change())
    self.layer.events.translate.connect(lambda e: self._on_translate_change())


# Traceback (TypeError)
(1, 10, 2, 15, 256, 256, 1)
BTCZYX0
(1, 10, 2, 15, 256, 256)
Dim PosT :  1
Dim PosZ :  3
Dim PosC :  2
Scale Factors XYZ:  [1, 1, 1, 3.516, 1, 1]
(1, 10, 15, 256, 256)
Adding Channel:  AF555
(1, 10, 15, 256, 256)
Adding Channel:  AF488
WARNING: Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_qt\qt_viewer_buttons.py", line 173, in <lambda>
lambda state=self: self.change_ndisplay(state)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_qt\qt_viewer_buttons.py", line 178, in change_ndisplay
self.viewer.dims.ndisplay = 3
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\components\dims.py", line 205, in ndisplay
self.events.ndisplay()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 508, in __call__
self._invoke_callback(cb, event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 529, in _invoke_callback
cb_event=(cb, event),
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 523, in _invoke_callback
cb(event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\components\viewer_model.py", line 89, in <lambda>
self.dims.events.ndisplay.connect(lambda e: self._update_layers())
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\components\viewer_model.py", line 1018, in _update_layers
layer.dims.ndisplay = self.dims.ndisplay
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\components\dims.py", line 205, in ndisplay
self.events.ndisplay()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 508, in __call__
self._invoke_callback(cb, event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 529, in _invoke_callback
cb_event=(cb, event),
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 523, in _invoke_callback
cb(event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\layers\base\base.py", line 174, in <lambda>
self.dims.events.ndisplay.connect(lambda e: self._update_dims())
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\layers\base\base.py", line 372, in _update_dims
self._set_view_slice()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\layers\image\image.py", line 502, in _set_view_slice
self.events.set_data()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 508, in __call__
self._invoke_callback(cb, event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 529, in _invoke_callback
cb_event=(cb, event),
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 523, in _invoke_callback
cb(event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_base_layer.py", line 46, in <lambda>
self.layer.events.set_data.connect(lambda e: self._on_data_change())
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_image_layer.py", line 59, in _on_data_change
self._on_display_change()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_image_layer.py", line 48, in _on_display_change
self.reset()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_image_layer.py", line 216, in reset
self._reset_base()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_base_layer.py", line 165, in _reset_base
self._on_scale_change()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_image_layer.py", line 123, in _on_scale_change
self.layer.position = self._transform_position(self._position)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_base_layer.py", line 153, in _transform_position
transform.map(list(position))[: len(self.layer.dims.displayed)]
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\vispy\visuals\transforms\chain.py", line 148, in map
coords = tr.map(coords)
File "<decorator-gen-4>", line 2, in imap
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\vispy\visuals\transforms\_util.py", line 111, in arg_to_vec4
arg = as_vec4(arg)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\vispy\visuals\transforms\_util.py", line 81, in as_vec4
% obj.shape)
TypeError: not all arguments converted during string formatting
WARNING:vispy:Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_qt\qt_viewer_buttons.py", line 173, in <lambda>
lambda state=self: self.change_ndisplay(state)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_qt\qt_viewer_buttons.py", line 178, in change_ndisplay
self.viewer.dims.ndisplay = 3
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\components\dims.py", line 205, in ndisplay
self.events.ndisplay()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 508, in __call__
self._invoke_callback(cb, event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 529, in _invoke_callback
cb_event=(cb, event),
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 523, in _invoke_callback
cb(event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\components\viewer_model.py", line 89, in <lambda>
self.dims.events.ndisplay.connect(lambda e: self._update_layers())
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\components\viewer_model.py", line 1018, in _update_layers
layer.dims.ndisplay = self.dims.ndisplay
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\components\dims.py", line 205, in ndisplay
self.events.ndisplay()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 508, in __call__
self._invoke_callback(cb, event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 529, in _invoke_callback
cb_event=(cb, event),
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 523, in _invoke_callback
cb(event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\layers\base\base.py", line 174, in <lambda>
self.dims.events.ndisplay.connect(lambda e: self._update_dims())
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\layers\base\base.py", line 372, in _update_dims
self._set_view_slice()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\layers\image\image.py", line 502, in _set_view_slice
self.events.set_data()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 508, in __call__
self._invoke_callback(cb, event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 529, in _invoke_callback
cb_event=(cb, event),
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\util\event.py", line 523, in _invoke_callback
cb(event)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_base_layer.py", line 46, in <lambda>
self.layer.events.set_data.connect(lambda e: self._on_data_change())
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_image_layer.py", line 59, in _on_data_change
self._on_display_change()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_image_layer.py", line 48, in _on_display_change
self.reset()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_image_layer.py", line 216, in reset
self._reset_base()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_base_layer.py", line 165, in _reset_base
self._on_scale_change()
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_image_layer.py", line 123, in _on_scale_change
self.layer.position = self._transform_position(self._position)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\napari\_vispy\vispy_base_layer.py", line 153, in _transform_position
transform.map(list(position))[: len(self.layer.dims.displayed)]
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\vispy\visuals\transforms\chain.py", line 148, in map
coords = tr.map(coords)
File "<decorator-gen-4>", line 2, in imap
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\vispy\visuals\transforms\_util.py", line 111, in arg_to_vec4
arg = as_vec4(arg)
File "C:\ProgramData\Anaconda3\envs\imageanalysis\lib\site-packages\vispy\visuals\transforms\_util.py", line 81, in as_vec4
% obj.shape)
TypeError: not all arguments converted during string formatting

# Fixed code
def __init__(self, layer, node):
    super().__init__()

    self.layer = layer
    self.node = node
    self._position = (0,) * self.layer.dims.ndisplay
    self.camera = None

    self.layer.events.refresh.connect(lambda e: self.node.update())
    self.layer.events.set_data.connect(lambda e: self._on_data_change())

    self.layer.events.visible.connect(lambda e: self._on_visible_change())
    self.layer.events.opacity.connect(lambda e: self._on_opacity_change())
    self.layer.events.blending.connect(lambda e: self._on_blending_change())
    self.layer.events.scale.connect(lambda e: self._on_scale_change())
    self.layer.events.translate.connect(lambda e: self._on_translate_change())