Example #1
0
 def add_function(self, id):
     if isinstance(id, int) and self.available_functions[id] is not None:
         func = function_class_from_function(self.available_functions[id])()
     elif isinstance(id, FitFunction):
         func = id
     self.functions.append(func)
     project.undolist.append(AddFitFunctionCommand(self, func, len(self.functions)-1))
Example #2
0
 def add_function(self, id):
     if isinstance(id, int) and self.available_functions[id] is not None:
         func = function_class_from_function(self.available_functions[id])()
     elif isinstance(id, FitFunction):
         func = id
     self.functions.append(func)
     project.undolist.append(
         AddFitFunctionCommand(self, func,
                               len(self.functions) - 1))
Example #3
0
    def from_element(self, elem):
        self.destroy_ui()
        self.functions = []
        try:
            instnames = pyget(elem, "inst_names")
        except:
            instnames = [None for f in pyget(elem, "names")]

        try:
            self.extra_properties = pyget(elem, "extra_properties")
        except:
            pass

        try:
            self.maxiter = pyget(elem, "max_iterations")
        except:
            pass

        try:
            self.resultsws = pyget(elem, "resultsws")
        except:
            pass

        for name, varshare, instname in zip(pyget(elem, "names"),
                                            pyget(elem, "varshares"),
                                            instnames):
            try:
                id = [f.name for f in self.available_functions].index(name)
            except ValueError:  # function not available
                print >> sys.stderr, "Function not available: %s" % (name, )
                continue
            func = function_class_from_function(self.available_functions[id])()
            func.varshare = varshare
            func.inst_name = instname
            self.functions.append(func)
        self.graph.fitdatasets = [
            self.graph.datasets[i] for i in pyget(elem, "datasets")
        ]
        self.params_flat_to_func(pyget(elem, "params")[0])
        self.build_ui()
Example #4
0
    def from_element(self, elem):
        self.destroy_ui()
        self.functions = []
        try:
            instnames = pyget(elem, "inst_names")
        except:
            instnames = [None for f in pyget(elem, "names")]

        try:
            self.extra_properties = pyget(elem, "extra_properties")
        except:
            pass

        try:
            self.maxiter = pyget(elem, "max_iterations")
        except:
            pass

        try:
            self.resultsws = pyget(elem, "resultsws")
        except:
            pass

        for name, varshare, instname in zip(pyget(elem, "names"), pyget(elem, "varshares"), instnames):
            try:
                id = [f.name for f in self.available_functions].index(name)
            except ValueError: # function not available
                print >>sys.stderr, "Function not available: %s" % (name,)
                continue
            func = function_class_from_function(self.available_functions[id])()
            func.varshare = varshare
            func.inst_name = instname
            self.functions.append(func)
        self.graph.fitdatasets = [self.graph.datasets[i] for i in pyget(elem, "datasets")]
        self.params_flat_to_func(pyget(elem, "params")[0])
        self.build_ui()