Exemplo n.º 1
0
    def __init__(self, parent: QWidget = None):
        """Initializes the FitFunctionOptionsView and sets up the fit options table and FunctionBrowser."""
        super(FitFunctionOptionsView, self).__init__(parent)
        self.setupUi(self)

        self.start_x_line_edit = None
        self.start_x_validator = None
        self.end_x_line_edit = None
        self.end_x_validator = None
        self.exclude_range_checkbox = None
        self.exclude_start_x_line_edit = None
        self.exclude_start_x_validator = None
        self.exclude_end_x_line_edit = None
        self.exclude_end_x_validator = None
        self.minimizer_combo = None
        self.fit_to_raw_data_checkbox = None
        self.evaluation_combo = None
        self.plot_guess_type_combo = None
        self.plot_guess_points_spin_box = None
        self.plot_guess_start_x_line_edit = None
        self.plot_guess_start_x_validator = None
        self.plot_guess_end_x_line_edit = None
        self.plot_guess_end_x_validator = None

        self._setup_fit_options_table()
        self.set_exclude_start_and_end_x_visible(self.exclude_range)

        self.function_browser = FunctionBrowser(self, True)
        self.function_browser_layout.addWidget(self.function_browser)
        self.function_browser.setErrorsEnabled(True)
        self.function_browser.hideGlobalCheckbox()
        self.function_browser.setStretchLastColumn(True)
Exemplo n.º 2
0
    def __init__(self, parent=None):
        super(FittingTabView, self).__init__(parent)
        self.setupUi(self)
        self.setup_fit_options_table()

        self.function_browser = FunctionBrowser(self, True)
        self.function_browser_layout.addWidget(self.function_browser)
        self.function_browser.setErrorsEnabled(True)

        self.increment_parameter_display_button.clicked.connect(
            self.increment_display_combo_box)
        self.decrement_parameter_display_button.clicked.connect(
            self.decrement_display_combo_box)
Exemplo n.º 3
0
    def __init__(self, simultaneous_item_list, is_frequency_domain=False, parent=None):
        super(FittingTabView, self).__init__(parent)
        self.setupUi(self)
        self.setup_fit_options_table()
        self.setup_simul_fit_combo_box(simultaneous_item_list)
        self.undo_fit_button.setEnabled(False)

        self.function_browser = FunctionBrowser(self, True)
        self.function_browser_layout.addWidget(self.function_browser)
        self.function_browser.setErrorsEnabled(True)
        self.function_browser.hideGlobalCheckbox()

        self.increment_parameter_display_button.clicked.connect(self.increment_display_combo_box)
        self.decrement_parameter_display_button.clicked.connect(self.decrement_display_combo_box)

        self.disable_simul_fit_options()

        if is_frequency_domain:
            self.hide_simultaneous_fit_options()
            self.fit_options_table.hideRow(RAW_DATA_TABLE_ROW)
            self.fit_options_table.hideRow(TF_ASYMMETRY_MODE_TABLE_ROW)
            table_utils.setRowName(self.fit_options_table, FIT_START_TABLE_ROW, "Start X")
            table_utils.setRowName(self.fit_options_table, FIT_END_TABLE_ROW, "End X")
            self.end_time = DEFAULT_FREQUENCY_FIT_END_X
Exemplo n.º 4
0
class FittingTabView(QtWidgets.QWidget, ui_fitting_tab):
    def __init__(self, parent=None):
        super(FittingTabView, self).__init__(parent)
        self.setupUi(self)
        self.setup_fit_options_table()
        self.setup_simul_fit_combo_box()
        self.undo_fit_button.setEnabled(False)

        self.function_browser = FunctionBrowser(self, True)
        self.function_browser_layout.addWidget(self.function_browser)
        self.function_browser.setErrorsEnabled(True)
        self.function_browser.hideGlobalCheckbox()

        self.increment_parameter_display_button.clicked.connect(
            self.increment_display_combo_box)
        self.decrement_parameter_display_button.clicked.connect(
            self.decrement_display_combo_box)

        self.disable_simul_fit_options()

    def update_displayed_data_combo_box(self, data_list):
        self.parameter_display_combo.blockSignals(True)
        name = self.parameter_display_combo.currentText()
        self.parameter_display_combo.clear()

        self.parameter_display_combo.addItems(data_list)

        index = self.parameter_display_combo.findText(name)

        if index != -1:
            self.parameter_display_combo.setCurrentIndex(index)
        else:
            self.parameter_display_combo.setCurrentIndex(0)

        self.parameter_display_combo.blockSignals(False)

    def increment_display_combo_box(self):
        index = self.parameter_display_combo.currentIndex()
        count = self.parameter_display_combo.count()

        if index < count - 1:
            self.parameter_display_combo.setCurrentIndex(index + 1)
        else:
            self.parameter_display_combo.setCurrentIndex(0)

    def decrement_display_combo_box(self):
        index = self.parameter_display_combo.currentIndex()
        count = self.parameter_display_combo.count()

        if index != 0:
            self.parameter_display_combo.setCurrentIndex(index - 1)
        else:
            self.parameter_display_combo.setCurrentIndex(count - 1)

    def setup_simul_fit_combo_box(self):
        self.simul_fit_by_combo.addItem("Run")
        self.simul_fit_by_combo.addItem("Group/Pair")

    def set_datasets_in_function_browser(self, data_set_name_list):
        number_of_data_sets = self.function_browser.getNumberOfDatasets()
        index_list = range(number_of_data_sets)
        self.function_browser.removeDatasets(index_list)
        self.function_browser.addDatasets(data_set_name_list)

    def update_with_fit_outputs(self, fit_function, output_status,
                                output_chi_squared):
        if not fit_function:
            self.fit_status_success_failure.setText('No Fit')
            self.fit_status_success_failure.setStyleSheet('color: black')
            self.fit_status_chi_squared.setText(
                'Chi squared: {}'.format(output_chi_squared))
            return

        if self.is_simul_fit():
            self.function_browser.blockSignals(True)
            self.function_browser.updateMultiDatasetParameters(fit_function)
            self.function_browser.blockSignals(False)
        else:
            self.function_browser.blockSignals(True)
            self.function_browser.updateParameters(fit_function)
            self.function_browser.blockSignals(False)

        if output_status == 'success':
            self.fit_status_success_failure.setText('Success')
            self.fit_status_success_failure.setStyleSheet('color: green')
        elif output_status is None:
            self.fit_status_success_failure.setText('No Fit')
            self.fit_status_success_failure.setStyleSheet('color: black')
        else:
            self.fit_status_success_failure.setText(
                'Failure: {}'.format(output_status))
            self.fit_status_success_failure.setStyleSheet('color: red')

        self.fit_status_chi_squared.setText(
            'Chi squared: {:.4g}'.format(output_chi_squared))

    def update_global_fit_state(self, output_list):
        if self.fit_type == self.simultaneous_fit:
            indexed_fit = output_list[self.get_index_for_start_end_times()]
            boolean_list = [indexed_fit == 'success'] if indexed_fit else []
        else:
            boolean_list = [
                output == 'success' for output in output_list if output
            ]

        if not boolean_list:
            self.global_fit_status_label.setText('No Fit')
            self.global_fit_status_label.setStyleSheet('color: black')
            return

        if all(boolean_list):
            self.global_fit_status_label.setText('Fit Successful')
            self.global_fit_status_label.setStyleSheet('color: green')
        else:
            self.global_fit_status_label.setText('{} of {} fits failed'.format(
                len(boolean_list) - sum(boolean_list), len(boolean_list)))
            self.global_fit_status_label.setStyleSheet('color: red')

    def set_slot_for_select_workspaces_to_fit(self, slot):
        self.select_workspaces_to_fit_button.clicked.connect(slot)

    def set_slot_for_display_workspace_changed(self, slot):
        self.parameter_display_combo.currentIndexChanged.connect(slot)

    def set_slot_for_use_raw_changed(self, slot):
        self.fit_to_raw_data_checkbox.stateChanged.connect(slot)

    def set_slot_for_fit_type_changed(self, slot):
        self.simul_fit_checkbox.toggled.connect(slot)

    def set_slot_for_fit_button_clicked(self, slot):
        self.fit_button.clicked.connect(slot)

    def set_slot_for_start_x_updated(self, slot):
        self.time_start.editingFinished.connect(slot)

    def set_slot_for_end_x_updated(self, slot):
        self.time_end.editingFinished.connect(slot)

    def set_slot_for_simul_fit_by_changed(self, slot):
        self.simul_fit_by_combo.currentIndexChanged.connect(slot)

    def set_slot_for_simul_fit_specifier_changed(self, slot):
        self.simul_fit_by_specifier.currentIndexChanged.connect(slot)

    def set_slot_for_fit_options_changed(self, slot):
        self.fit_options_table.cellChanged.connect(slot)

    @property
    def display_workspace(self):
        return str(self.parameter_display_combo.currentText())

    @property
    def fit_object(self):
        return self.function_browser.getGlobalFunction()

    @property
    def minimizer(self):
        return str(self.minimizer_combo.currentText())

    @property
    def start_time(self):
        return float(self.time_start.text())

    @start_time.setter
    def start_time(self, value):
        self.time_start.setText(str(value))

    @property
    def end_time(self):
        return float(self.time_end.text())

    @end_time.setter
    def end_time(self, value):
        self.time_end.setText(str(value))

    @property
    def evaluation_type(self):
        return str(self.evaluation_combo.currentText())

    @property
    def fit_type(self):
        if self.simul_fit_checkbox.isChecked():
            return self.simul_fit_checkbox.text()

    @property
    def simultaneous_fit(self):
        return self.simul_fit_checkbox.text()

    @property
    def simultaneous_fit_by(self):
        return self.simul_fit_by_combo.currentText()

    @property
    def simultaneous_fit_by_specifier(self):
        return self.simul_fit_by_specifier.currentText()

    @property
    def fit_to_raw(self):
        return self.fit_to_raw_data_checkbox.isChecked()

    @fit_to_raw.setter
    def fit_to_raw(self, value):
        state = QtCore.Qt.Checked if value else QtCore.Qt.Unchecked
        self.fit_to_raw_data_checkbox.setCheckState(state)

    @property
    def plot_guess(self):
        return self.plot_guess_checkbox.isChecked()

    @plot_guess.setter
    def plot_guess(self, value):
        state = QtCore.Qt.Checked if value else QtCore.Qt.Unchecked
        self.plot_guess_checkbox.setCheckState(state)

    @property
    def tf_asymmetry_mode(self):
        return self.tf_asymmetry_mode_checkbox.isChecked()

    @tf_asymmetry_mode.setter
    def tf_asymmetry_mode(self, value):
        state = QtCore.Qt.Checked if value else QtCore.Qt.Unchecked
        self.tf_asymmetry_mode_checkbox.setCheckState(state)

    @property
    def function_name(self):
        return str(self.function_name_line_edit.text())

    @function_name.setter
    def function_name(self, function_name):
        self.function_name_line_edit.blockSignals(True)
        self.function_name_line_edit.setText(function_name)
        self.function_name_line_edit.blockSignals(False)

    def warning_popup(self, message):
        warning(message, parent=self)

    def get_index_for_start_end_times(self):
        current_index = self.parameter_display_combo.currentIndex()
        return current_index if current_index != -1 else 0

    def get_global_parameters(self):
        return self.function_browser.getGlobalParameters()

    def switch_to_simultaneous(self):
        self.function_browser.showGlobalCheckbox()

    def switch_to_single(self):
        self.function_browser.hideGlobalCheckbox()

    def disable_simul_fit_options(self):
        self.simul_fit_by_combo.setEnabled(False)
        self.simul_fit_by_specifier.setEnabled(False)
        self.select_workspaces_to_fit_button.setEnabled(False)

    def enable_simul_fit_options(self):
        self.simul_fit_by_combo.setEnabled(True)
        self.simul_fit_by_specifier.setEnabled(True)

    def is_simul_fit(self):
        return self.simul_fit_checkbox.isChecked()

    def setup_fit_by_specifier(self, choices):
        self.simul_fit_by_specifier.blockSignals(True)
        self.simul_fit_by_specifier.clear()
        self.simul_fit_by_specifier.addItems(choices)
        self.simul_fit_by_specifier.blockSignals(False)
        self.simul_fit_by_specifier.currentIndexChanged.emit(0)

    def setup_fit_options_table(self):
        self.fit_options_table.setRowCount(6)
        self.fit_options_table.setColumnCount(2)
        self.fit_options_table.setColumnWidth(0, 150)
        self.fit_options_table.setColumnWidth(1, 300)
        self.fit_options_table.verticalHeader().setVisible(False)
        self.fit_options_table.horizontalHeader().setStretchLastSection(True)
        self.fit_options_table.setHorizontalHeaderLabels(
            ("Property;Value").split(";"))

        table_utils.setRowName(self.fit_options_table, 0, "Time Start")
        self.time_start = table_utils.addDoubleToTable(self.fit_options_table,
                                                       0.0, 0, 1)

        table_utils.setRowName(self.fit_options_table, 1, "Time End")
        self.time_end = table_utils.addDoubleToTable(self.fit_options_table,
                                                     15.0, 1, 1)

        table_utils.setRowName(self.fit_options_table, 2, "Minimizer")
        self.minimizer_combo = table_utils.addComboToTable(
            self.fit_options_table, 2, [])
        self.minimizer_combo.addItems(allowed_minimizers)

        table_utils.setRowName(self.fit_options_table, 3, "Fit To Raw Data")
        self.fit_to_raw_data_checkbox = table_utils.addCheckBoxWidgetToTable(
            self.fit_options_table, True, 3)

        table_utils.setRowName(self.fit_options_table, 4, "TF Asymmetry Mode")
        self.tf_asymmetry_mode_checkbox = table_utils.addCheckBoxWidgetToTable(
            self.fit_options_table, False, 4)

        table_utils.setRowName(self.fit_options_table, 5,
                               "Evaluate Function As")
        self.evaluation_combo = table_utils.addComboToTable(
            self.fit_options_table, 5, ['CentrePoint', 'Histogram'])
Exemplo n.º 5
0
 def create_widget(self):
     return FunctionBrowser(None, self.is_multi)
Exemplo n.º 6
0
class FitFunctionOptionsView(ui_form, base_widget):
    """
    The FitFunctionOptionsView includes the Function Name line edit, FunctionBrowser and the fitting options table
    widget. It also holds the Fit Status and Chi Squared labels.
    """
    def __init__(self, parent: QWidget = None):
        """Initializes the FitFunctionOptionsView and sets up the fit options table and FunctionBrowser."""
        super(FitFunctionOptionsView, self).__init__(parent)
        self.setupUi(self)

        self.start_x_line_edit = None
        self.start_x_validator = None
        self.end_x_line_edit = None
        self.end_x_validator = None
        self.exclude_range_checkbox = None
        self.exclude_start_x_line_edit = None
        self.exclude_start_x_validator = None
        self.exclude_end_x_line_edit = None
        self.exclude_end_x_validator = None
        self.minimizer_combo = None
        self.fit_to_raw_data_checkbox = None
        self.evaluation_combo = None
        self.plot_guess_type_combo = None
        self.plot_guess_points_spin_box = None
        self.plot_guess_start_x_line_edit = None
        self.plot_guess_start_x_validator = None
        self.plot_guess_end_x_line_edit = None
        self.plot_guess_end_x_validator = None

        self._setup_fit_options_table()
        self.set_exclude_start_and_end_x_visible(self.exclude_range)

        self.function_browser = FunctionBrowser(self, True)
        self.function_browser_layout.addWidget(self.function_browser)
        self.function_browser.setErrorsEnabled(True)
        self.function_browser.hideGlobalCheckbox()
        self.function_browser.setStretchLastColumn(True)

    def set_slot_for_covariance_matrix_clicked(self, slot) -> None:
        """Connect the slot for the Covariance Matrix button being clicked."""
        self.covariance_matrix_button.clicked.connect(slot)

    def set_slot_for_fit_name_changed(self, slot) -> None:
        """Connect the slot for the fit name being changed by the user."""
        self.function_name_line_edit.textChanged.connect(slot)

    def set_slot_for_function_structure_changed(self, slot) -> None:
        """Connect the slot for the function structure changing."""
        self.function_browser.functionStructureChanged.connect(slot)

    def set_slot_for_function_parameter_changed(self, slot) -> None:
        """Connect the slot for a function parameter changing."""
        self.function_browser.parameterChanged.connect(slot)

    def set_slot_for_function_attribute_changed(self, slot) -> None:
        """Connect the slot for a function attribute changing."""
        self.function_browser.attributeChanged.connect(slot)

    def set_slot_for_start_x_updated(self, slot) -> None:
        """Connect the slot for the start x option."""
        self.start_x_line_edit.editingFinished.connect(slot)

    def set_slot_for_end_x_updated(self, slot) -> None:
        """Connect the slot for the end x option."""
        self.end_x_line_edit.editingFinished.connect(slot)

    def set_slot_for_exclude_range_state_changed(self, slot) -> None:
        """Connect the slot for the exclude range checkbox."""
        self.exclude_range_checkbox.stateChanged.connect(slot)

    def set_slot_for_exclude_start_x_updated(self, slot) -> None:
        """Connect the slot for the exclude start x option."""
        self.exclude_start_x_line_edit.editingFinished.connect(slot)

    def set_slot_for_exclude_end_x_updated(self, slot) -> None:
        """Connect the slot for the exclude end x option."""
        self.exclude_end_x_line_edit.editingFinished.connect(slot)

    def set_slot_for_minimizer_changed(self, slot) -> None:
        """Connect the slot for changing the Minimizer."""
        self.minimizer_combo.currentIndexChanged.connect(slot)

    def set_slot_for_evaluation_type_changed(self, slot) -> None:
        """Connect the slot for changing the Evaluation type."""
        self.evaluation_combo.currentIndexChanged.connect(slot)

    def set_slot_for_plot_guess_type_changed(self, slot) -> None:
        """Connect the slot for changing the guess type."""
        self.plot_guess_type_combo.currentIndexChanged.connect(slot)

    def set_slot_for_plot_guess_points_updated(self, slot) -> None:
        """Connect the slot for the start x option."""
        self.plot_guess_points_spin_box.valueChanged.connect(slot)

    def set_slot_for_plot_guess_start_x_updated(self, slot) -> None:
        """Connect the slot for the start x option."""
        self.plot_guess_start_x_line_edit.editingFinished.connect(slot)

    def set_slot_for_plot_guess_end_x_updated(self, slot) -> None:
        """Connect the slot for the end x option."""
        self.plot_guess_end_x_line_edit.editingFinished.connect(slot)

    def set_slot_for_use_raw_changed(self, slot) -> None:
        """Connect the slot for the Use raw option."""
        self.fit_to_raw_data_checkbox.stateChanged.connect(slot)

    def update_fit_status_labels(self, fit_status: str,
                                 chi_squared: float) -> None:
        """Updates the fit status and chi squared label."""
        if fit_status == "success":
            self.fit_status_success_failure.setText("Success")
            self.fit_status_success_failure.setStyleSheet("color: green")
        elif fit_status is None:
            self.fit_status_success_failure.setText("No Fit")
            self.fit_status_success_failure.setStyleSheet("color: black")
        else:
            self.fit_status_success_failure.setText(f"Failure: {fit_status}")
            self.fit_status_success_failure.setStyleSheet("color: red")
        self.fit_status_chi_squared.setText(f"Chi squared: {chi_squared:.4g}")

    def clear_fit_status(self) -> None:
        """Clears the fit status and chi squared label."""
        self.fit_status_success_failure.setText("No Fit")
        self.fit_status_success_failure.setStyleSheet("color: black")
        self.fit_status_chi_squared.setText(f"Chi squared: 0.0")

    def set_datasets_in_function_browser(self, dataset_names: list) -> None:
        """Sets the datasets stored in the FunctionBrowser."""
        index_list = range(self.function_browser.getNumberOfDatasets())
        self.function_browser.removeDatasets(index_list)
        self.function_browser.addDatasets(dataset_names)

    def set_current_dataset_index(self, dataset_index: int) -> None:
        """Sets the index of the current dataset."""
        self.function_browser.setCurrentDataset(dataset_index)

    def set_fit_function(self, fit_function: IFunction) -> None:
        """Set the fit function shown in the view."""
        self.function_browser.blockSignals(True)
        if fit_function is None:
            self.function_browser.setFunction("")
        else:
            self.function_browser.setFunction(str(fit_function))
            # Required to update the parameter errors as they are not stored in the function string
            self.function_browser.updateParameters(fit_function)
        self.function_browser.blockSignals(False)
        self.function_browser.setErrorsEnabled(True)

    def update_function_browser_parameters(
            self,
            is_simultaneous_fit: bool,
            fit_function: IFunction,
            global_parameters: list = []) -> None:
        """Updates the parameters in the function browser."""
        self.function_browser.blockSignals(True)

        if fit_function is None:
            self.function_browser.setFunction("")
        elif is_simultaneous_fit:
            self.function_browser.updateMultiDatasetParameters(
                fit_function.clone())
            self.global_parameters = global_parameters
        else:
            self.function_browser.updateParameters(fit_function)

        self.function_browser.blockSignals(False)
        self.function_browser.setErrorsEnabled(True)

    @property
    def fit_object(self) -> IFunction:
        """Returns the global fitting function."""
        return self.function_browser.getGlobalFunction()

    def current_fit_function(self) -> IFunction:
        """Returns the current fitting function in the view."""
        return self.function_browser.getFunction()

    @property
    def minimizer(self) -> str:
        """Returns the selected minimizer."""
        return str(self.minimizer_combo.currentText())

    @property
    def start_x(self) -> float:
        """Returns the selected start X."""
        return float(self.start_x_line_edit.text())

    @start_x.setter
    def start_x(self, value: float) -> None:
        """Sets the selected start X."""
        self.start_x_validator.last_valid_value = f"{value:.3f}"
        self.start_x_line_edit.setText(f"{value:.3f}")

    @property
    def end_x(self) -> float:
        """Returns the selected end X."""
        return float(self.end_x_line_edit.text())

    @end_x.setter
    def end_x(self, value: float) -> None:
        """Sets the selected end X."""
        self.end_x_validator.last_valid_value = f"{value:.3f}"
        self.end_x_line_edit.setText(f"{value:.3f}")

    @property
    def exclude_range(self) -> bool:
        """Returns true if the Exclude Range option is ticked."""
        return self.exclude_range_checkbox.isChecked()

    @property
    def exclude_start_x(self) -> float:
        """Returns the start X for the excluded region."""
        return float(self.exclude_start_x_line_edit.text())

    @exclude_start_x.setter
    def exclude_start_x(self, value: float) -> None:
        """Sets the selected exclude start X."""
        self.exclude_start_x_validator.last_valid_value = f"{value:.3f}"
        self.exclude_start_x_line_edit.setText(f"{value:.3f}")

    @property
    def exclude_end_x(self) -> float:
        """Returns the end X for the excluded region."""
        return float(self.exclude_end_x_line_edit.text())

    @exclude_end_x.setter
    def exclude_end_x(self, value: float) -> None:
        """Sets the selected exclude end X."""
        self.exclude_end_x_validator.last_valid_value = f"{value:.3f}"
        self.exclude_end_x_line_edit.setText(f"{value:.3f}")

    @property
    def plot_guess_type(self) -> str:
        """Returns the guess range type."""
        return str(self.plot_guess_type_combo.currentText())

    @property
    def plot_guess_points(self) -> int:
        """Returns the points for the guess fit."""
        return int(self.plot_guess_points_spin_box.value())

    @property
    def plot_guess_start_x(self) -> float:
        """Returns the guess start X."""
        return float(self.plot_guess_start_x_line_edit.text())

    @plot_guess_start_x.setter
    def plot_guess_start_x(self, value: float) -> None:
        """Sets the selected start X."""
        self.plot_guess_start_x_validator.last_valid_value = f"{value:.3f}"
        self.plot_guess_start_x_line_edit.setText(f"{value:.3f}")

    @property
    def plot_guess_end_x(self) -> float:
        """Returns the guess end X."""
        return float(self.plot_guess_end_x_line_edit.text())

    @plot_guess_end_x.setter
    def plot_guess_end_x(self, value: float) -> None:
        """Sets the selected start X."""
        self.plot_guess_end_x_validator.last_valid_value = f"{value:.3f}"
        self.plot_guess_end_x_line_edit.setText(f"{value:.3f}")

    @property
    def evaluation_type(self) -> str:
        """Returns the selected evaluation type."""
        return str(self.evaluation_combo.currentText())

    @property
    def fit_to_raw(self) -> bool:
        """Returns whether or not fitting to raw data is ticked."""
        return self.fit_to_raw_data_checkbox.isChecked()

    @fit_to_raw.setter
    def fit_to_raw(self, check: bool) -> None:
        """Sets whether or not you are fitting to raw data."""
        self.fit_to_raw_data_checkbox.setCheckState(
            Qt.Checked if check else Qt.Unchecked)

    @property
    def function_name(self) -> str:
        """Returns the function name being used."""
        return str(self.function_name_line_edit.text())

    @function_name.setter
    def function_name(self, function_name: str) -> None:
        """Sets the function name being used."""
        self.function_name_line_edit.blockSignals(True)
        self.function_name_line_edit.setText(function_name)
        self.function_name_line_edit.blockSignals(False)

    def number_of_datasets(self) -> int:
        """Returns the number of domains in the FunctionBrowser."""
        return self.function_browser.getNumberOfDatasets()

    @property
    def global_parameters(self) -> list:
        """Returns a list of global parameters."""
        return self.function_browser.getGlobalParameters()

    @global_parameters.setter
    def global_parameters(self, global_parameters: list) -> None:
        """Sets the global parameters in the function browser."""
        self.function_browser.setGlobalParameters(global_parameters)

    def parameter_value(self, full_parameter: str) -> float:
        """Returns the value of the specified parameter."""
        return self.function_browser.getParameter(full_parameter)

    def attribute_value(self, full_attribute: str):
        """Returns the value of the specified attribute."""
        return self.current_fit_function().getAttributeValue(full_attribute)

    def switch_to_simultaneous(self) -> None:
        """Switches the view to simultaneous mode."""
        self.function_browser.showGlobalCheckbox()
        self.function_browser.setGlobalParameters([])

    def switch_to_single(self) -> None:
        """Switches the view to single mode."""
        self.function_browser.hideGlobalCheckbox()
        self.function_browser.setGlobalParameters([])

    def hide_exclude_range_checkbox(self) -> None:
        """Hides the Exclude Range checkbox in the fitting options."""
        self.fit_options_table.hideRow(EXCLUDE_RANGE_TABLE_ROW)

    def hide_fit_raw_checkbox(self) -> None:
        """Hides the Fit Raw checkbox in the fitting options."""
        self.fit_options_table.hideRow(RAW_DATA_TABLE_ROW)

    def hide_evaluate_function_as_checkbox(self) -> None:
        """Hides the Evaluate Function as checkbox in the fitting options."""
        self.fit_options_table.hideRow(EVALUATE_AS_TABLE_ROW)

    def set_start_and_end_x_labels(self, start_x_label: str,
                                   end_x_label: str) -> None:
        """Sets the labels to use for the start and end X labels in the fit options table."""
        table_utils.setRowName(self.fit_options_table, START_X_TABLE_ROW,
                               start_x_label)
        table_utils.setRowName(self.fit_options_table, END_X_TABLE_ROW,
                               end_x_label)
        table_utils.setRowName(self.fit_options_table,
                               EXCLUDE_START_X_TABLE_ROW,
                               f"Exclude {start_x_label}")
        table_utils.setRowName(self.fit_options_table, EXCLUDE_END_X_TABLE_ROW,
                               f"Exclude {end_x_label}")

    def set_exclude_start_and_end_x_visible(self, visible: bool) -> None:
        """Sets whether the exclude start and end x options are visible."""
        if visible:
            self.fit_options_table.showRow(EXCLUDE_START_X_TABLE_ROW)
            self.fit_options_table.showRow(EXCLUDE_END_X_TABLE_ROW)
        else:
            self.fit_options_table.hideRow(EXCLUDE_START_X_TABLE_ROW)
            self.fit_options_table.hideRow(EXCLUDE_END_X_TABLE_ROW)

    def set_covariance_button_enabled(self, enabled: bool) -> None:
        """Sets whether the Covariance Matrix button is enabled or not."""
        self.covariance_matrix_button.setEnabled(enabled)

    def show_normalised_covariance_matrix(self, covariance_ws: ITableWorkspace,
                                          workspace_name: str) -> None:
        """Shows the normalised covariance matrix in a separate table display window."""
        table_display = TableWorkspaceDisplay(covariance_ws,
                                              parent=self,
                                              name=workspace_name)
        table_display.show_view()

    def _setup_fit_options_table(self) -> None:
        """Setup the fit options table with the appropriate options."""
        self.fit_options_table.setRowCount(12)
        self.fit_options_table.setColumnCount(2)
        self.fit_options_table.setColumnWidth(0, 150)
        self.fit_options_table.verticalHeader().setVisible(False)
        self.fit_options_table.horizontalHeader().setStretchLastSection(True)
        self.fit_options_table.setHorizontalHeaderLabels(["Property", "Value"])

        table_utils.setRowName(self.fit_options_table, START_X_TABLE_ROW,
                               "Start X")
        self.start_x_line_edit, self.start_x_validator = table_utils.addDoubleToTable(
            self.fit_options_table, 0.0, START_X_TABLE_ROW, 1)

        table_utils.setRowName(self.fit_options_table, END_X_TABLE_ROW,
                               "End X")
        self.end_x_line_edit, self.end_x_validator = table_utils.addDoubleToTable(
            self.fit_options_table, 15.0, END_X_TABLE_ROW, 1)

        table_utils.setRowName(self.fit_options_table, EXCLUDE_RANGE_TABLE_ROW,
                               "Exclude Range")
        self.exclude_range_checkbox = table_utils.addCheckBoxWidgetToTable(
            self.fit_options_table, False, EXCLUDE_RANGE_TABLE_ROW)

        table_utils.setRowName(self.fit_options_table,
                               EXCLUDE_START_X_TABLE_ROW, "Exclude Start X")
        self.exclude_start_x_line_edit, self.exclude_start_x_validator = table_utils.addDoubleToTable(
            self.fit_options_table, 15.0, EXCLUDE_START_X_TABLE_ROW, 1)

        table_utils.setRowName(self.fit_options_table, EXCLUDE_END_X_TABLE_ROW,
                               "Exclude End X")
        self.exclude_end_x_line_edit, self.exclude_end_x_validator = table_utils.addDoubleToTable(
            self.fit_options_table, 15.0, EXCLUDE_END_X_TABLE_ROW, 1)

        table_utils.setRowName(self.fit_options_table, RAW_DATA_TABLE_ROW,
                               "Fit To Raw Data")
        self.fit_to_raw_data_checkbox = table_utils.addCheckBoxWidgetToTable(
            self.fit_options_table, True, RAW_DATA_TABLE_ROW)

        table_utils.setRowName(self.fit_options_table, MINIMIZER_TABLE_ROW,
                               "Minimizer")
        self.minimizer_combo = table_utils.addComboToTable(
            self.fit_options_table, MINIMIZER_TABLE_ROW, [])
        self.minimizer_combo.addItems(ALLOWED_MINIMIZERS)

        table_utils.setRowName(self.fit_options_table, EVALUATE_AS_TABLE_ROW,
                               "Evaluate Function As")
        self.evaluation_combo = table_utils.addComboToTable(
            self.fit_options_table, EVALUATE_AS_TABLE_ROW,
            ['CentrePoint', 'Histogram'])

        table_utils.setRowName(self.fit_options_table, PLOT_GUESS_TYPE,
                               "Plot guess using")
        self.plot_guess_type_combo = table_utils.addComboToTable(
            self.fit_options_table, PLOT_GUESS_TYPE,
            [X_FROM_FIT_RANGE, X_FROM_DATA_RANGE, X_FROM_CUSTOM])

        table_utils.setRowName(self.fit_options_table, PLOT_GUESS_POINTS,
                               "Points")
        self.plot_guess_points_spin_box = table_utils.addSpinBoxToTable(
            self.fit_options_table, 1000, PLOT_GUESS_POINTS)
        self.plot_guess_points_spin_box.setMinimum(1)
        self.show_plot_guess_points(False)

        table_utils.setRowName(self.fit_options_table, PLOT_GUESS_START_X,
                               "Start X")
        self.plot_guess_start_x_line_edit, self.plot_guess_start_x_validator = table_utils.addDoubleToTable(
            self.fit_options_table, 0.0, PLOT_GUESS_START_X, 1)
        self.show_plot_guess_start_x(False)

        table_utils.setRowName(self.fit_options_table, PLOT_GUESS_END_X,
                               "End X")
        self.plot_guess_end_x_line_edit, self.plot_guess_end_x_validator = table_utils.addDoubleToTable(
            self.fit_options_table, 15.0, PLOT_GUESS_END_X, 1)
        self.show_plot_guess_end_x(False)

    def show_plot_guess_points(self, show: bool = True) -> None:
        if show:
            self.fit_options_table.showRow(PLOT_GUESS_POINTS)
        else:
            self.fit_options_table.hideRow(PLOT_GUESS_POINTS)

    def show_plot_guess_start_x(self, show: bool = True) -> None:
        if show:
            self.fit_options_table.showRow(PLOT_GUESS_START_X)
        else:
            self.fit_options_table.hideRow(PLOT_GUESS_START_X)

    def show_plot_guess_end_x(self, show: bool = True) -> None:
        if show:
            self.fit_options_table.showRow(PLOT_GUESS_END_X)
        else:
            self.fit_options_table.hideRow(PLOT_GUESS_END_X)