def METHOD_NAME(self, index, value, role=Qt.ItemDataRole.EditRole):
    """
    Sets a time period or a value in the pattern.
    Column index 0 corresponds to the time periods while 1 corresponds to the values.
    Args:
        index (QModelIndex): an index to the model
        value (str, float): a new time period or value
        role (int): a role
    Returns:
        bool: True if the operation was successful
    """
    if not index.isValid() or role != Qt.ItemDataRole.EditRole:
        return False
    row = index.row()
    if row == len(self._value):
        self.insertRow(row)
    if index.column() == 0:
        try:
            self._value.indexes[row] = value
        except ParameterValueFormatError as error:
            QMessageBox.warning(self.parent(), "Error", str(error))
            return False
    else:
        self._value.values[row] = value
    self.dataChanged.emit(index, index, [Qt.ItemDataRole.EditRole])
    return True