<commit_before>
class FitEngine:
    
    def _concatenateData(self, listdata=[]):
        """  
            _concatenateData method concatenates each fields of all data contains ins listdata.
            @param listdata: list of data 
            
            @return xtemp, ytemp,dytemp:  x,y,dy respectively of data all combined
                if xi,yi,dyi of two or more data are the same the second appearance of xi,yi,
                dyi is ignored in the concatenation.
                
            @raise: if listdata is empty  will return None
            @raise: if data in listdata don't contain dy field ,will create an error
            during fitting
        """
        if listdata==[]:
            raise ValueError, " data list missing"
        else:
            xtemp=[]
            ytemp=[]
            dytemp=[]
               
            for data in listdata:
                for i in range(len(data.x)):
                    xtemp.append(data.x[i])
                    ytemp.append(data.y[i])
                    if data.dy is not None and len(data.dy)==len(data.y):   
                        dytemp.append(data.dy[i])
                    else:
                        raise RuntimeError, "Fit._concatenateData: y-errors missinge"
            return xtemp, ytemp,dytemp
    
    def set_model(self,model,name,Uid,pars={}):
        """ 
      
            Receive a dictionary of parameter and save it Parameter list
            For scipy.fit use.
            Set model in a FitArrange object and add that object in a dictionary
            with key Uid.
            @param model: model on with parameter values are set
            @param name: model name
            @param Uid: unique key corresponding to a fitArrange object with model
            @param pars: dictionary of paramaters name and value
            pars={parameter's name: parameter's value}
            
        """
        self.parameters=[]
        if model==None:
            raise ValueError, "Cannot set parameters for empty model"
        else:
            model.name=name
            for key, value in pars.iteritems():
                param = Parameter(model, key, value)
                self.parameters.append(param)
        
        #A fitArrange is already created but contains dList only at Uid
        if self.fitArrangeList.has_key(Uid):
            self.fitArrangeList[Uid].set_model(model)
        else:
        #no fitArrange object has been create with this Uid
            fitproblem= FitArrange()
            fitproblem.set_model(model)
            self.fitArrangeList[Uid]=fitproblem
        
        
    def set_data(self,data,Uid):
        """ Receives plottable, creates a list of data to fit,set data
            in a FitArrange object and adds that object in a dictionary 
            with key Uid.
            @param data: data added
            @param Uid: unique key corresponding to a fitArrange object with data
            """
        #A fitArrange is already created but contains model only at Uid
        if self.fitArrangeList.has_key(Uid):
            self.fitArrangeList[Uid].add_data(data)
        else:
        #no fitArrange object has been create with this Uid
            fitproblem= FitArrange()
            fitproblem.add_data(data)
            self.fitArrangeList[Uid]=fitproblem
            
    def get_model(self,Uid):
        """ 
            @param Uid: Uid is key in the dictionary containing the model to return
            @return  a model at this uid or None if no FitArrange element was created
            with this Uid
        """
        if self.fitArrangeList.has_key(Uid):
            return self.fitArrangeList[Uid].get_model()
        else:
            return None
    
    def remove_Fit_Problem(self,Uid):<commit_msg>modified setmodel<commit_after>
class FitEngine:
    
    def _concatenateData(self, listdata=[]):
        """  
            _concatenateData method concatenates each fields of all data contains ins listdata.
            @param listdata: list of data 
            
            @return xtemp, ytemp,dytemp:  x,y,dy respectively of data all combined
                if xi,yi,dyi of two or more data are the same the second appearance of xi,yi,
                dyi is ignored in the concatenation.
                
            @raise: if listdata is empty  will return None
            @raise: if data in listdata don't contain dy field ,will create an error
            during fitting
        """
        if listdata==[]:
            raise ValueError, " data list missing"
        else:
            xtemp=[]
            ytemp=[]
            dytemp=[]
               
            for data in listdata:
                for i in range(len(data.x)):
                    xtemp.append(data.x[i])
                    ytemp.append(data.y[i])
                    if data.dy is not None and len(data.dy)==len(data.y):   
                        dytemp.append(data.dy[i])
                    else:
                        raise RuntimeError, "Fit._concatenateData: y-errors missinge"
            return xtemp, ytemp,dytemp
    
    def set_model(self,model,name,Uid,pars={}):
        """ 
      
            Receive a dictionary of parameter and save it Parameter list
            For scipy.fit use.
            Set model in a FitArrange object and add that object in a dictionary
            with key Uid.
            @param model: model on with parameter values are set
            @param name: model name
            @param Uid: unique key corresponding to a fitArrange object with model
            @param pars: dictionary of paramaters name and value
            pars={parameter's name: parameter's value}
            
        """
        if pars !={}:
            self.parameters=[]
            if model==None:
                raise ValueError, "Cannot set parameters for empty model"
            else:
                model.name=name
                for key, value in pars.iteritems():
                    param = Parameter(model, key, value)
                    self.parameters.append(param)
            
            #A fitArrange is already created but contains dList only at Uid
            if self.fitArrangeList.has_key(Uid):
                self.fitArrangeList[Uid].set_model(model)
            else:
            #no fitArrange object has been create with this Uid
                fitproblem= FitArrange()
                fitproblem.set_model(model)
                self.fitArrangeList[Uid]=fitproblem
        else:
            raise ValueError, "park_integration:missing parameters"
        
        
    def set_data(self,data,Uid):
        """ Receives plottable, creates a list of data to fit,set data
            in a FitArrange object and adds that object in a dictionary 
            with key Uid.
            @param data: data added
            @param Uid: unique key corresponding to a fitArrange object with data
            """
        #A fitArrange is already created but contains model only at Uid
        if self.fitArrangeList.has_key(Uid):
            self.fitArrangeList[Uid].add_data(data)
        else:
        #no fitArrange object has been create with this Uid
            fitproblem= FitArrange()
            fitproblem.add_data(data)
            self.fitArrangeList[Uid]=fitproblem
            
    def get_model(self,Uid):
        """ 
            @param Uid: Uid is key in the dictionary containing the model to return
            @return  a model at this uid or None if no FitArrange element was created
            with this Uid
        """
        if self.fitArrangeList.has_key(Uid):
            return self.fitArrangeList[Uid].get_model()
        else:
            return None
    
    def remove_Fit_Problem(self,Uid):
{'fraction_non_alphanumeric': 0.06708106708106708, 'fraction_numerical': 0.0, 'mean_word_length': 1.6038435603506407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4316625', 'n_tokens_mistral': 2076, 'n_tokens_neox': 1987, 'n_words': 691}