# Buggy code
def track_labels(self) -> tuple:
    """return track labels at the current time"""

    # check that current time is still within the frame map
    if self.current_time < 0 or self.current_time > self._manager.max_time:
        # need to return a tuple for pos to clear the vispy text visual
        return None, (None, None)

    labels, positions = self._manager.track_labels(self.current_time)
    padded_positions = self._pad_display_data(positions)
    return labels, padded_positions


# Traceback (ValueError)
ERROR:root:Unhandled exception:
Traceback (most recent call last):
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/_qt/event_loop.py", line 79, in gui_qt
yield app
File "<ipython-input-2-498e4844dd1f>", line 9, in <module>
Tracks = napari.view_tracks(tracks_data,name='tracks')
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/view_layers.py", line 9, in view_tracks
(where <layer_type> is replaced with one of the layer types):
File "<string>", line 3, in add_tracks
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/components/add_layers_mixin.py", line 72, in add_layer
self.layers.append(layer)
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/utils/list/_model.py", line 59, in append
self.events.added(item=obj, index=len(self) - 1)
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/utils/events/event.py", line 514, in __call__
self._invoke_callback(cb, event)
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/utils/events/event.py", line 531, in _invoke_callback
_handle_exception(
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/utils/events/event.py", line 529, in _invoke_callback
cb(event)
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/_qt/qt_viewer.py", line 323, in _add_layer
vispy_layer = create_vispy_visual(layer)
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/_vispy/utils.py", line 44, in create_vispy_visual
return visual(layer)
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/_vispy/vispy_tracks_layer.py", line 50, in __init__
self._on_data_change()
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/_vispy/vispy_tracks_layer.py", line 62, in _on_data_change
labels_text, labels_pos = self.layer.track_labels
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/layers/tracks/tracks.py", line 543, in track_labels
padded_positions = self._pad_display_data(positions)
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/napari/layers/tracks/tracks.py", line 306, in _pad_display_data
data = np.pad(data, ((0, 0), (0, 1)), 'constant')
File "<__array_function__ internals>", line 5, in pad
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/numpy/lib/arraypad.py", line 748, in pad
pad_width = _as_pairs(pad_width, array.ndim, as_index=True)
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/numpy/lib/arraypad.py", line 523, in _as_pairs
return np.broadcast_to(x, (ndim, 2)).tolist()
File "<__array_function__ internals>", line 5, in broadcast_to
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/numpy/lib/stride_tricks.py", line 182, in broadcast_to
return _broadcast_to(array, shape, subok=subok, readonly=True)
File "/home/kapoorlab/anaconda3/envs/tensorflowGPU/lib/python3.8/site-packages/numpy/lib/stride_tricks.py", line 125, in _broadcast_to
it = np.nditer(
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (2,2) and requested shape (3,2)

# Fixed code
def track_labels(self) -> tuple:
    """return track labels at the current time"""
    labels, positions = self._manager.track_labels(self.current_time)

    # if there are no labels, return empty for vispy
    if not labels:
        return None, (None, None)

    padded_positions = self._pad_display_data(positions)
    return labels, padded_positions