Beispiel #1
0
 def format_numbers_to_be_displayed(value_list):
     """ This function formats and beautify the number to be shown on the graph.
     """
     new_mark_list = list()
     for value in value_list:
         if value >= 10:
             precision = 1
         else:
             precision = 2
         value_str = formatNumber(str(value), precision)
         new_mark_list.append(value_str)
     return new_mark_list
Beispiel #2
0
    def data(self, index, role):
        if not index.isValid():
            return None

        getDecorationBoxes = (role == Qt.DecorationRole
                              and index.column() == 1)

        if role != Qt.DisplayRole and not getDecorationBoxes:
            return None

        call_tree_node = index.internalPointer().data()
        if call_tree_node is None:
            return "Invalid"

        callpath = call_tree_node.path
        if callpath is None:
            return "Invalid"

        model = self.getSelectedModel(callpath)
        if model is None and index.column() != 0:
            return None

        if getDecorationBoxes:
            delta = self.main_widget.max_value - self.main_widget.min_value
            if delta == 0:
                return None  # can't divide by zero

            # code commented for single-parameter model
            '''
            paramValueList = EXTRAP.ParameterValueList()
            parameters = self.main_widget.experiment.getParameters()
            paramValueList[ parameters[0] ] = self.main_widget.spinBox.value()
            formula = model.hypothesis.function
            value = formula.evaluate( paramValueList )
            '''

            # added for two-parameter models here
            parameters = self.selector_widget.getParameterValues()
            formula = model.hypothesis.function
            previous = numpy.seterr(divide='ignore', invalid='ignore')
            value = formula.evaluate(parameters)
            numpy.seterr(**previous)

            # convert value to relative value between 0 and 1
            relativeValue = max(0.0,
                                (value - self.main_widget.min_value) / delta)

            return self.main_widget.color_widget.getColor(relativeValue)

        if index.column() == 0:
            return call_tree_node.name
        elif index.column() == 2:
            # if len(model.getComments()) > 0:
            #     return len(model.getComments())
            return None
        elif index.column() == 3:
            experiment = self.main_widget.getExperiment()
            formula = model.hypothesis.function
            if self.selector_widget.asymptoticCheckBox.isChecked():
                parameters = tuple(experiment.parameters)
                return formatFormula(formula.to_string(*parameters))
            else:
                parameters = self.selector_widget.getParameterValues()
                previous = numpy.seterr(divide='ignore', invalid='ignore')
                res = formatNumber(str(formula.evaluate(parameters)))
                numpy.seterr(**previous)
                return res
        elif index.column() == 4:
            return formatNumber(str(model.hypothesis.RSS))
        elif index.column() == 5:
            return formatNumber(str(model.hypothesis.AR2))
        elif index.column() == 6:
            return formatNumber(str(model.hypothesis.SMAPE))
        elif index.column() == 7:
            return formatNumber(str(model.hypothesis.RE))
        return None
Beispiel #3
0
 def update_min_max(self, min_value, max_value):
     self.min_label.setText(formatNumber(str(min_value)))
     self.max_label.setText(formatNumber(str(max_value)))