code: def fit(self, **kwargs):
          
          if len(self._set_xdata)==0 or len(self._set_ydata)==0:
              return self._error("No data. Please use set_data() prior to fitting.")
          if self._f_raw is None:
              return self._error("No functions. Please use set_functions() prior to fitting.")
  
          # Do the processing once, to increase efficiency
          self._massage_data()
          
          # Send the keyword arguments to the settings
          self.set(**kwargs)
  
          # do the actual optimization
          self.results = _opt.leastsq(self._studentized_residuals_concatenated, self._pguess, full_output=1)
  
          # plot if necessary
          if self['autoplot']: self.plot()
  
          return self
docs: This will try to determine fit parameters using scipy.optimize.leastsq
          algorithm. This function relies on a previous call of set_data() and 
          set_functions().
  
          Notes
          -----
          results of the fit algorithm are stored in self.results. 
          See scipy.optimize.leastsq for more information.
  
          Optional keyword arguments are sent to self.set() prior to
          fitting.