'Add `rows` to selection. If `heatmap` is provided the rows
are mapped from the local indices to global heatmap indices. If `clear`
then remove previous rows.'

def select_rows(self, rows, heatmap=None, clear=True):

    if (heatmap is not None):
        (start, _) = self._heatmap_ranges[heatmap]
        rows = [(start + r) for r in rows]
    old_selection = list(self.selections)
    if clear:
        self.selections = rows
    else:
        self.selections = sorted(set((self.selections + rows)))
    if (self.selections != old_selection):
        self.update_selection_rects()
        self.selection_changed.emit()
