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

    self.layer.events.mode.connect(self.set_mode)
    self.layer.events.n_dimensional.connect(self._on_n_dim_change)
    self.layer.events.symbol.connect(self._on_symbol_change)
    self.layer.events.size.connect(self._on_size_change)
    self.layer.events.edge_color.connect(self._on_edge_color_change)
    self.layer.events.face_color.connect(self._on_face_color_change)
    self.layer.events.editable.connect(self._on_editable_change)

    sld = QSlider(Qt.Horizontal)
    sld.setFocusPolicy(Qt.NoFocus)
    sld.setMinimum(1)
    sld.setMaximum(100)
    sld.setSingleStep(1)
    value = self.layer.current_size
    sld.setValue(int(value))
    sld.valueChanged.connect(self.changeSize)
    self.sizeSlider = sld

    face_comboBox = QComboBox()
    face_comboBox.addItems(self.layer._colors)
    face_comboBox.activated[str].connect(self.changeFaceColor)
    self.faceComboBox = face_comboBox
    self.faceColorSwatch = QFrame()
    self.faceColorSwatch.setObjectName("swatch")
    self.faceColorSwatch.setToolTip("Face color swatch")
    self._on_face_color_change()

    edge_comboBox = QComboBox()
    edge_comboBox.addItems(self.layer._colors)
    edge_comboBox.activated[str].connect(self.changeEdgeColor)
    self.edgeComboBox = edge_comboBox
    self.edgeColorSwatch = QFrame()
    self.edgeColorSwatch.setObjectName("swatch")
    self.edgeColorSwatch.setToolTip("Edge color swatch")
    self._on_edge_color_change()

    symbol_comboBox = QComboBox()
    symbol_comboBox.addItems([str(s) for s in Symbol])
    index = symbol_comboBox.findText(self.layer.symbol, Qt.MatchFixedString)
    symbol_comboBox.setCurrentIndex(index)
    symbol_comboBox.activated[str].connect(self.changeSymbol)
    self.symbolComboBox = symbol_comboBox

    ndim_cb = QCheckBox()
    ndim_cb.setToolTip("N-dimensional points")
    ndim_cb.setChecked(self.layer.n_dimensional)
    ndim_cb.stateChanged.connect(self.change_ndim)
    self.ndimCheckBox = ndim_cb

    self.select_button = QtModeRadioButton(
        layer, "select_points", Mode.SELECT, tooltip="Select points"
    )
    self.addition_button = QtModeRadioButton(
        layer, "add_points", Mode.ADD, tooltip="Add points"
    )
    self.panzoom_button = QtModeRadioButton(
        layer, "pan_zoom", Mode.PAN_ZOOM, tooltip="Pan/zoom", checked=True
    )
    self.delete_button = QtModePushButton(
        layer,
        "delete_shape",
        slot=self.layer.remove_selected,
        tooltip="Delete selected points",
    )

    self.button_group = QButtonGroup(self)
    self.button_group.addButton(self.select_button)
    self.button_group.addButton(self.addition_button)
    self.button_group.addButton(self.panzoom_button)

    button_row = QHBoxLayout()
    button_row.addWidget(self.delete_button)
    button_row.addWidget(self.addition_button)
    button_row.addWidget(self.select_button)
    button_row.addWidget(self.panzoom_button)
    button_row.addStretch(1)
    button_row.setSpacing(4)

    # grid_layout created in QtLayerControls
    # addWidget(widget, row, column, [row_span, column_span])
    self.grid_layout.addLayout(button_row, 0, 1, 1, 2)
    self.grid_layout.addWidget(QLabel("opacity:"), 1, 0)
    self.grid_layout.addWidget(self.opacitySlider, 1, 1, 1, 2)
    self.grid_layout.addWidget(QLabel("point size:"), 2, 0)
    self.grid_layout.addWidget(self.sizeSlider, 2, 1, 1, 2)
    self.grid_layout.addWidget(QLabel("blending:"), 3, 0)
    self.grid_layout.addWidget(self.blendComboBox, 3, 1, 1, 2)
    self.grid_layout.addWidget(QLabel("symbol:"), 4, 0)
    self.grid_layout.addWidget(self.symbolComboBox, 4, 1, 1, 2)
    self.grid_layout.addWidget(QLabel("face color:"), 5, 0)
    self.grid_layout.addWidget(self.faceComboBox, 5, 2)
    self.grid_layout.addWidget(self.faceColorSwatch, 5, 1)
    self.grid_layout.addWidget(QLabel("edge color:"), 6, 0)
    self.grid_layout.addWidget(self.edgeComboBox, 6, 2)
    self.grid_layout.addWidget(self.edgeColorSwatch, 6, 1)
    self.grid_layout.addWidget(QLabel("n-dim:"), 7, 0)
    self.grid_layout.addWidget(self.ndimCheckBox, 7, 1)
    self.grid_layout.setRowStretch(8, 1)
    self.grid_layout.setColumnStretch(1, 1)
    self.grid_layout.setSpacing(4)


# Traceback (ValueError)
WARNING: Traceback (most recent call last):
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/_qt/qt_viewer_buttons.py", line 173, in <lambda>
lambda state=self: self.change_ndisplay(state)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/_qt/qt_viewer_buttons.py", line 178, in change_ndisplay
self.viewer.dims.ndisplay = 3
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/components/dims.py", line 296, in ndisplay
self.events.ndisplay()
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 508, in __call__
self._invoke_callback(cb, event)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 529, in _invoke_callback
cb_event=(cb, event),
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 523, in _invoke_callback
cb(event)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/components/viewer_model.py", line 88, in <lambda>
self.dims.events.ndisplay.connect(lambda e: self._update_layers())
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/components/viewer_model.py", line 1037, in _update_layers
layer.dims.ndisplay = self.dims.ndisplay
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/components/dims.py", line 296, in ndisplay
self.events.ndisplay()
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 508, in __call__
self._invoke_callback(cb, event)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 529, in _invoke_callback
cb_event=(cb, event),
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 523, in _invoke_callback
cb(event)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/base/base.py", line 180, in <lambda>
self.dims.events.ndisplay.connect(lambda e: self._update_dims())
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/base/base.py", line 383, in _update_dims
self.refresh()
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/base/base.py", line 600, in refresh
self._set_view_slice()
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/points/points.py", line 654, in _set_view_slice
self._selected_box = self.interaction_box(self._selected_view)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/points/points.py", line 480, in interaction_box
data = points_to_squares(data, size)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/points/points.py", line 972, in points_to_squares
points + np.sqrt(2) / 2 * np.array([sizes, sizes]).T,
ValueError: operands could not be broadcast together with shapes (1,3) (1,2)
WARNING:vispy:Traceback (most recent call last):
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/_qt/qt_viewer_buttons.py", line 173, in <lambda>
lambda state=self: self.change_ndisplay(state)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/_qt/qt_viewer_buttons.py", line 178, in change_ndisplay
self.viewer.dims.ndisplay = 3
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/components/dims.py", line 296, in ndisplay
self.events.ndisplay()
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 508, in __call__
self._invoke_callback(cb, event)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 529, in _invoke_callback
cb_event=(cb, event),
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 523, in _invoke_callback
cb(event)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/components/viewer_model.py", line 88, in <lambda>
self.dims.events.ndisplay.connect(lambda e: self._update_layers())
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/components/viewer_model.py", line 1037, in _update_layers
layer.dims.ndisplay = self.dims.ndisplay
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/components/dims.py", line 296, in ndisplay
self.events.ndisplay()
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 508, in __call__
self._invoke_callback(cb, event)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 529, in _invoke_callback
cb_event=(cb, event),
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/utils/event.py", line 523, in _invoke_callback
cb(event)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/base/base.py", line 180, in <lambda>
self.dims.events.ndisplay.connect(lambda e: self._update_dims())
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/base/base.py", line 383, in _update_dims
self.refresh()
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/base/base.py", line 600, in refresh
self._set_view_slice()
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/points/points.py", line 654, in _set_view_slice
self._selected_box = self.interaction_box(self._selected_view)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/points/points.py", line 480, in interaction_box
data = points_to_squares(data, size)
File "/home/hagai/.conda/envs/ncd/lib/python3.7/site-packages/napari/layers/points/points.py", line 972, in points_to_squares
points + np.sqrt(2) / 2 * np.array([sizes, sizes]).T,
ValueError: operands could not be broadcast together with shapes (1,3) (1,2)

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

    self.layer.events.mode.connect(self.set_mode)
    self.layer.events.n_dimensional.connect(self._on_n_dim_change)
    self.layer.events.symbol.connect(self._on_symbol_change)
    self.layer.events.size.connect(self._on_size_change)
    self.layer.events.current_edge_color.connect(self._on_edge_color_change)
    self.layer.events.current_face_color.connect(self._on_face_color_change)
    self.layer.events.editable.connect(self._on_editable_change)

    sld = QSlider(Qt.Horizontal)
    sld.setFocusPolicy(Qt.NoFocus)
    sld.setMinimum(1)
    sld.setMaximum(100)
    sld.setSingleStep(1)
    value = self.layer.current_size
    sld.setValue(int(value))
    sld.valueChanged.connect(self.changeSize)
    self.sizeSlider = sld

    face_comboBox = QComboBox()
    face_comboBox.addItems(self.layer._colors)
    face_comboBox.activated[str].connect(self.changeFaceColor)
    self.faceComboBox = face_comboBox
    self.faceColorSwatch = QFrame()
    self.faceColorSwatch.setObjectName("swatch")
    self.faceColorSwatch.setToolTip("Face color swatch")
    self._on_face_color_change()

    edge_comboBox = QComboBox()
    edge_comboBox.addItems(self.layer._colors)
    edge_comboBox.activated[str].connect(self.changeEdgeColor)
    self.edgeComboBox = edge_comboBox
    self.edgeColorSwatch = QFrame()
    self.edgeColorSwatch.setObjectName("swatch")
    self.edgeColorSwatch.setToolTip("Edge color swatch")
    self._on_edge_color_change()

    symbol_comboBox = QComboBox()
    symbol_comboBox.addItems([str(s) for s in Symbol])
    index = symbol_comboBox.findText(self.layer.symbol, Qt.MatchFixedString)
    symbol_comboBox.setCurrentIndex(index)
    symbol_comboBox.activated[str].connect(self.changeSymbol)
    self.symbolComboBox = symbol_comboBox

    ndim_cb = QCheckBox()
    ndim_cb.setToolTip("N-dimensional points")
    ndim_cb.setChecked(self.layer.n_dimensional)
    ndim_cb.stateChanged.connect(self.change_ndim)
    self.ndimCheckBox = ndim_cb

    self.select_button = QtModeRadioButton(
        layer, "select_points", Mode.SELECT, tooltip="Select points"
    )
    self.addition_button = QtModeRadioButton(
        layer, "add_points", Mode.ADD, tooltip="Add points"
    )
    self.panzoom_button = QtModeRadioButton(
        layer, "pan_zoom", Mode.PAN_ZOOM, tooltip="Pan/zoom", checked=True
    )
    self.delete_button = QtModePushButton(
        layer,
        "delete_shape",
        slot=self.layer.remove_selected,
        tooltip="Delete selected points",
    )

    self.button_group = QButtonGroup(self)
    self.button_group.addButton(self.select_button)
    self.button_group.addButton(self.addition_button)
    self.button_group.addButton(self.panzoom_button)

    button_row = QHBoxLayout()
    button_row.addWidget(self.delete_button)
    button_row.addWidget(self.addition_button)
    button_row.addWidget(self.select_button)
    button_row.addWidget(self.panzoom_button)
    button_row.addStretch(1)
    button_row.setSpacing(4)

    # grid_layout created in QtLayerControls
    # addWidget(widget, row, column, [row_span, column_span])
    self.grid_layout.addLayout(button_row, 0, 1, 1, 2)
    self.grid_layout.addWidget(QLabel("opacity:"), 1, 0)
    self.grid_layout.addWidget(self.opacitySlider, 1, 1, 1, 2)
    self.grid_layout.addWidget(QLabel("point size:"), 2, 0)
    self.grid_layout.addWidget(self.sizeSlider, 2, 1, 1, 2)
    self.grid_layout.addWidget(QLabel("blending:"), 3, 0)
    self.grid_layout.addWidget(self.blendComboBox, 3, 1, 1, 2)
    self.grid_layout.addWidget(QLabel("symbol:"), 4, 0)
    self.grid_layout.addWidget(self.symbolComboBox, 4, 1, 1, 2)
    self.grid_layout.addWidget(QLabel("face color:"), 5, 0)
    self.grid_layout.addWidget(self.faceComboBox, 5, 2)
    self.grid_layout.addWidget(self.faceColorSwatch, 5, 1)
    self.grid_layout.addWidget(QLabel("edge color:"), 6, 0)
    self.grid_layout.addWidget(self.edgeComboBox, 6, 2)
    self.grid_layout.addWidget(self.edgeColorSwatch, 6, 1)
    self.grid_layout.addWidget(QLabel("n-dim:"), 7, 0)
    self.grid_layout.addWidget(self.ndimCheckBox, 7, 1)
    self.grid_layout.setRowStretch(8, 1)
    self.grid_layout.setColumnStretch(1, 1)
    self.grid_layout.setSpacing(4)