Index: park_integration/AbstractFitEngine.py
===================================================================
--- park_integration/AbstractFitEngine.py	(revision 388309d5e5ef39b5f0eb98585a131c6fe6a052c8)
+++ park_integration/AbstractFitEngine.py	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
@@ -9,10 +9,24 @@
     """
     def __init__(self, name, model):
-         self._model, self._name = model,name
-         self.set(model.getParam(name))
+        """
+            @param name: the name of the model parameter
+            @param model: the sans model to wrap as a park model
+        """
+        self._model, self._name = model,name
+        #set the value for the parameter of the given name
+        self.set(model.getParam(name))
          
-    def _getvalue(self): return self._model.getParam(self.name)
-    
-    def _setvalue(self,value): 
+    def _getvalue(self):
+        """
+            override the _getvalue of park parameter
+            @return value the parameter associates with self.name
+        """
+        return self._model.getParam(self.name)
+    
+    def _setvalue(self,value):
+        """
+            override the _setvalue pf park parameter
+            @param value: the value to set on a given parameter
+        """
         self._model.setParam(self.name, value)
         
@@ -20,4 +34,8 @@
     
     def _getrange(self):
+        """
+            Override _getrange of park parameter
+            return the range of parameter
+        """
         lo,hi = self._model.details[self.name][1:]
         if lo is None: lo = -numpy.inf
@@ -26,4 +44,8 @@
     
     def _setrange(self,r):
+        """
+            override _setrange of park parameter
+            @param r: the value of the range to set
+        """
         self._model.details[self.name][1:] = r
     range = property(_getrange,_setrange)
@@ -35,17 +57,23 @@
     """
     def __init__(self, sans_model, **kw):
+        """
+            @param sans_model: the sans model to wrap using park interface
+        """
         self.model = sans_model
-        self.name=sans_model.name
-        #print "ParkFitting:sans model",self.model
+        self.name = sans_model.name
+        #list of parameters names
         self.sansp = sans_model.getParamList()
-        #print "ParkFitting: sans model parameter list",sansp
+        #list of park parameter
         self.parkp = [SansParameter(p,sans_model) for p in self.sansp]
-        #print "ParkFitting: park model parameter ",self.parkp
+        #list of parameterset 
         self.parameterset = park.ParameterSet(sans_model.name,pars=self.parkp)
         self.pars=[]
-      
-    #def __call__(self, x, pars=[]):
-    #    return self.eval(x)   
+  
+  
     def getParams(self,fitparams):
+        """
+            return a list of value of paramter to fit
+            @param fitparams: list of paramaters name to fit
+        """
         list=[]
         self.pars=[]
@@ -55,8 +83,12 @@
                  if element.name ==str(item):
                      list.append(element.value)
-        #print "abstractfitengine: getparams",list
         return list
     
+    
     def setParams(self, params):
+        """
+            Set value for parameters to fit
+            @param params: list of value for parameters to fit 
+        """
         list=[]
         for item in self.parkp:
@@ -65,27 +97,22 @@
         for i in range(len(params)):
             self.parkp[i].value = params[i]
-            print "abstractfitengine: set-params",list[i],params[i]
-            
             self.model.setParam(list[i],params[i])
   
+  
     def eval(self,x):
-       
+        """
+            override eval method of park model. 
+            @param x: the x value used to compute a function
+        """
         return self.model.runXY(x)
    
-    #def set(self, **kw):
-        #"""
-            #Set the initial value for a set of parameters.
-            #E.g., model.set(width=3,center=5)
-        #"""
-        #print "Abstractfitting : set called"
-        # This is a convenience funciton for the user.
-        # 
-        #for k,v in kw.items(): 
-        #    self.parameterset[k].set(v)
    
 class Data(object):
     """ Wrapper class  for SANS data """
     def __init__(self,x=None,y=None,dy=None,dx=None,sans_data=None):
-        
+        """
+            Data can be initital with a data (sans plottable)
+            or with vectors.
+        """
         if  sans_data !=None:
             self.x= sans_data.x
@@ -105,10 +132,18 @@
         self.qmax=None
        
+       
     def setFitRange(self,mini=None,maxi=None):
         """ to set the fit range"""
         self.qmin=mini
         self.qmax=maxi
+        
+        
     def getFitRange(self):
-         return self.qmin, self.qmax
+        """
+            @return the range of data.x to fit
+        """
+        return self.qmin, self.qmax
+     
+     
     def residuals(self, fn):
         """ @param fn: function that return model value
@@ -117,9 +152,9 @@
         x,y,dy = [numpy.asarray(v) for v in (self.x,self.y,self.dy)]
         if self.qmin==None and self.qmax==None: 
-            fx =[fn(v) for v in x]
+            fx =numpy.asarray([fn(v) for v in x])
             return (y - fx)/dy
         else:
             idx = (x>=self.qmin) & (x <= self.qmax)
-            fx = [fn(item)for item in x[idx ]]
+            fx = numpy.asarray([fn(item)for item in x[idx ]])
             return (y[idx] - fx)/dy[idx]
           
@@ -134,8 +169,15 @@
     
 class sansAssembly:
+    """
+         Sans Assembly class a class wrapper to be call in optimizer.leastsq method
+    """
     def __init__(self,Model=None , Data=None):
-       self.model = Model
-       self.data  = Data
-       self.res=[]
+        """
+            @param Model: the model wrapper fro sans -model
+            @param Data: the data wrapper for sans data
+        """
+        self.model = Model
+        self.data  = Data
+        self.res=[]
     def chisq(self, params):
         """
@@ -149,4 +191,8 @@
         return sum
     def __call__(self,params):
+        """
+            Compute residuals
+            @param params: value of parameters to fit
+        """
         self.model.setParams(params)
         self.res= self.data.residuals(self.model.eval)
@@ -155,12 +201,18 @@
 class FitEngine:
     def __init__(self):
+        """
+            Base class for scipy and park fit engine
+        """
+        #List of parameter names to fit
         self.paramList=[]
+        #Dictionnary of fitArrange element (fit problems)
+        self.fitArrangeDict={}
+        
     def _concatenateData(self, listdata=[]):
         """  
             _concatenateData method concatenates each fields of all data contains ins listdata.
             @param listdata: list of data 
-            
-            @return Data:
-                
+            @return Data: Data is wrapper class for sans plottable. it is created with all parameters
+             of data concatenanted
             @raise: if listdata is empty  will return None
             @raise: if data in listdata don't contain dy field ,will create an error
@@ -195,25 +247,36 @@
                     else:
                         raise RuntimeError, "Fit._concatenateData: y-errors missing"
-            #return xtemp, ytemp,dytemp
             data= Data(x=xtemp,y=ytemp,dy=dytemp)
             data.setFitRange(self.mini, self.maxi)
             return data
-    def set_model(self,model,name,Uid,pars=[]):
+        
+        
+    def set_model(self,model,Uid,pars=[]):
+        """
+            set a model on a given uid in the fit engine.
+            @param model: the model to fit
+            @param Uid :is the key of the fitArrange dictionnary where model is saved as a value
+            @param pars: the list of parameters to fit 
+            @note : pars must contains only name of existing model's paramaters
+        """
         if len(pars) >0:
-            self.paramList = []
             if model==None:
                 raise ValueError, "AbstractFitEngine: Specify parameters to fit"
             else:
-                model.model.name = name
-                model.name = name
-                self.paramList=pars
+                for item in pars:
+                    if item in model.model.getParamList():
+                        self.paramList.append(item)
+                    else:
+                        raise ValueError,"wrong paramter %s used to set model %s. Choose\
+                            parameter name within %s"%(item, model.model.name,str(model.model.getParamList()))
+                        return
             #A fitArrange is already created but contains dList only at Uid
-            if self.fitArrangeList.has_key(Uid):
-                self.fitArrangeList[Uid].set_model(model)
+            if self.fitArrangeDict.has_key(Uid):
+                self.fitArrangeDict[Uid].set_model(model)
             else:
             #no fitArrange object has been create with this Uid
                 fitproblem = FitArrange()
                 fitproblem.set_model(model)
-                self.fitArrangeList[Uid] = fitproblem
+                self.fitArrangeDict[Uid] = fitproblem
         else:
             raise ValueError, "park_integration:missing parameters"
@@ -225,15 +288,15 @@
             @param data: data added
             @param Uid: unique key corresponding to a fitArrange object with data
-            """
+        """
         if qmin !=None and qmax !=None:
             data.setFitRange(mini=qmin,maxi=qmax)
         #A fitArrange is already created but contains model only at Uid
-        if self.fitArrangeList.has_key(Uid):
-            self.fitArrangeList[Uid].add_data(data)
+        if self.fitArrangeDict.has_key(Uid):
+            self.fitArrangeDict[Uid].add_data(data)
         else:
         #no fitArrange object has been create with this Uid
             fitproblem= FitArrange()
             fitproblem.add_data(data)
-            self.fitArrangeList[Uid]=fitproblem    
+            self.fitArrangeDict[Uid]=fitproblem    
    
     def get_model(self,Uid):
@@ -243,6 +306,6 @@
             with this Uid
         """
-        if self.fitArrangeList.has_key(Uid):
-            return self.fitArrangeList[Uid].get_model()
+        if self.fitArrangeDict.has_key(Uid):
+            return self.fitArrangeDict[Uid].get_model()
         else:
             return None
@@ -250,6 +313,6 @@
     def remove_Fit_Problem(self,Uid):
         """remove   fitarrange in Uid"""
-        if self.fitArrangeList.has_key(Uid):
-            del self.fitArrangeList[Uid]
+        if self.fitArrangeDict.has_key(Uid):
+            del self.fitArrangeDict[Uid]
 
     
Index: park_integration/Fitting.py
===================================================================
--- park_integration/Fitting.py	(revision 48882d14c03b61d8a22b600abadcccba552c8697)
+++ park_integration/Fitting.py	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
@@ -46,4 +46,5 @@
         else:
             raise ValueError, "enter the keyword scipy or park"
+        
     def returnEngine(self):
         """ @return self._engine""" 
@@ -53,9 +54,11 @@
         """Perform the fit """
         return self._engine.fit(qmin,qmax)
-    def set_model(self,model,name,Uid,pars=[]):
-         self._engine.set_model(model,name,Uid,pars)
+    
+    def set_model(self,model,Uid,pars=[]):
+         self._engine.set_model(model,Uid,pars)
    
     def set_data(self,data,Uid,qmin=None, qmax=None):
         self._engine.set_data(data,Uid,qmin,qmax)
+        
     def get_model(self,Uid):
         """ return list of data"""
@@ -65,2 +68,4 @@
         """remove   fitarrange in Uid"""
         self._engine.remove_Fit_Problem(Uid)
+        
+        
Index: park_integration/ParkFitting.py
===================================================================
--- park_integration/ParkFitting.py	(revision 388309d5e5ef39b5f0eb98585a131c6fe6a052c8)
+++ park_integration/ParkFitting.py	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
@@ -45,8 +45,8 @@
             with Uid as keys
         """
-        self.fitArrangeList={}
+        self.fitArrangeDict={}
         self.paramList=[]
         
-    def createProblem(self):
+    def createAssembly(self):
         """
         Extract sansmodel and sansdata from self.FitArrangelist ={Uid:FitArrange}
@@ -54,21 +54,11 @@
         create an assembly self.problem=  park.Assembly([(parkmodel,parkdata)])
         """
-        print "ParkFitting: In createproblem"
         mylist=[]
         listmodel=[]
         i=0
-        for k,value in self.fitArrangeList.iteritems():
-            #sansmodel=value.get_model()
-            #wrap sans model
-            #parkmodel = Model(sansmodel)
+        for k,value in self.fitArrangeDict.iteritems():
             parkmodel = value.get_model()
-            #print "ParkFitting: createproblem: just create a model",parkmodel.parameterset
             for p in parkmodel.parameterset:
-                #self.param_list.append(p._getname())
-                #if p.isfixed():
-                #print 'parameters',p.name
-                #print "parkfitting: self.paramList",self.paramList
                 if p.isfixed() and p._getname()in self.paramList:
-                #if p.isfixed():
                     p.set([-numpy.inf,numpy.inf])
             i+=1    
@@ -76,8 +66,7 @@
             parkdata=self._concatenateData(Ldata)
             
-            couple=(parkmodel,parkdata)
-            #print "Parkfitting: fitness",couple   
-            mylist.append(couple)
-        #print "mylist",mylist
+            fitness=(parkmodel,parkdata)
+            mylist.append(fitness)
+    
         self.problem =  park.Assembly(mylist)
         
@@ -99,32 +88,17 @@
             @return result.cov: Covariance matrix
         """
-        #from numpy.linalg.linalg.LinAlgError import LinAlgError
-        #print "Parkfitting: fit method probably breaking just right before \
-        #call fit"
-        self.createProblem()
+        
+        self.createAssembly()
         pars=self.problem.fit_parameters()
         self.problem.eval()
-        #print "M0.B",self.problem[1].parameterset['B'].value,self.problem[0].parameterset['B'].value
-
         localfit = FitSimplex()
         localfit.ftol = 1e-8
-        #localfit.ftol = 1e-6
         fitter = FitMC(localfit=localfit)
-        print "ParkFitting: result1",pars
-        print "Parkfitting: in fit function fitness resid",self.problem[0].residuals()
-        
         list=self.problem[0]._parameterset()
-        print "Parkfitting: in fit function fitness paramset",list
-        for item in list:
-            print "Parkfitting: in fit function fitness",item.name, item.value,item.path,item.range
         result = fit.fit(self.problem,
                      fitter=fitter,
                      handler= fitresult.ConsoleUpdate(improvement_delta=0.1))
-        #result = fit.fit(self.problem)
-        print "ParkFitting: result",result.fitness,result.pvec,result.cov
+       
         if result !=None:
-            #for p in result.parameters:
-            #    print "fit in park fitting", p.name, p.value,p.stderr
-            #return result.fitness,result.pvec,result.cov,result
             return result
         else:
Index: park_integration/ScipyFitting.py
===================================================================
--- park_integration/ScipyFitting.py	(revision 48882d14c03b61d8a22b600abadcccba552c8697)
+++ park_integration/ScipyFitting.py	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
@@ -35,5 +35,5 @@
         Use a sans model
         
-        Add data with a dictionnary of FitArrangeList where Uid is a key and data
+        Add data with a dictionnary of FitArrangeDict where Uid is a key and data
         is saved in FitArrange object.
         engine.set_data(data,Uid)
@@ -45,5 +45,5 @@
         engine.set_param( model,"M1", {'A':2,'B':4})
         
-        Add model with a dictionnary of FitArrangeList{} where Uid is a key and model
+        Add model with a dictionnary of FitArrangeDict{} where Uid is a key and model
         is save in FitArrange object.
         engine.set_model(model,Uid)
@@ -54,16 +54,16 @@
     def __init__(self):
         """
-            Creates a dictionary (self.fitArrangeList={})of FitArrange elements
+            Creates a dictionary (self.fitArrangeDict={})of FitArrange elements
             with Uid as keys
         """
-        self.fitArrangeList={}
+        self.fitArrangeDict={}
         self.paramList=[]
     def fit(self,qmin=None, qmax=None):
          # Protect against simultanous fitting attempts
-        if len(self.fitArrangeList)>1: 
+        if len(self.fitArrangeDict)>1: 
             raise RuntimeError, "Scipy can't fit more than a single fit problem at a time."
         
         # fitproblem contains first fitArrange object(one model and a list of data)
-        fitproblem=self.fitArrangeList.values()[0]
+        fitproblem=self.fitArrangeDict.values()[0]
         listdata=[]
         model = fitproblem.get_model()
@@ -77,21 +77,14 @@
             qmax= max(data.x) 
         functor= sansAssembly(model,data)
-        print "scipyfitting:param list",model.getParams(self.paramList)
-        print "scipyfitting:functor",functor(model.getParams(self.paramList))
-    
+       
         out, cov_x, info, mesg, success = optimize.leastsq(functor,model.getParams(self.paramList), full_output=1, warning=True)
         chisqr = functor.chisq(out)
+        if cov_x is not None and numpy.isfinite(cov_x).all():
+            stderr = numpy.sqrt(numpy.diag(cov_x))
         
-        print "scipyfitting: info",mesg
-        print"scipyfitting : success",success
-        print "scipyfitting: out", out
-        print "scipyfitting: cov_x", cov_x
-        print "scipyfitting: chisqr", chisqr
-        
-        if not (numpy.isnan(out).any()):
+        if not (numpy.isnan(out).any()) or ( cov_x !=None) :
                 result = fitresult()
                 result.fitness = chisqr
-                result.cov  = cov_x
-                
+                result.stderr  = stderr
                 result.pvec = out
                 result.success =success
@@ -99,5 +92,5 @@
                 return result
         else:  
-            raise ValueError, "SVD did not converge"
+            raise ValueError, "SVD did not converge"+str(success)
         
        
Index: park_integration/docs/use-cases.txt
===================================================================
--- park_integration/docs/use-cases.txt	(revision 103a0b01aacb82e91d4a8a969004d5972d1cf30f)
+++ park_integration/docs/use-cases.txt	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
@@ -23,4 +23,6 @@
 1.1.3.1. 	The user does not choose a data set before starting the fit.
 1.1.3.2. 	The user does not choose a model before starting the fit.
+1.1.3.3.	the user does not specify the list of parameter to fit 
+1.1.3.4.	the user enters a list of parameters that do not belong to the model
 
 
@@ -55,4 +57,5 @@
 
 2.1.2.1.	The client does not enter initial parameters
+2.1.2.2.	the user enters a list of parameters not belonging to the model
 
 
Index: park_integration/test/cyl_testdata.txt
===================================================================
--- park_integration/test/cyl_testdata.txt	(revision cfe97ea0b428b0187f4d80a432800b8dea085a37)
+++ park_integration/test/cyl_testdata.txt	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
@@ -1,4 +1,3 @@
 0.007778 1.78E+14 13335629 
-
 0.023333 5.32E+13 7293888 
 0.031111 3.40E+13 5833464 
@@ -12,5 +11,4 @@
 0.093333 1.47E+11 383624.8 
 0.101111 1.19E+11 344493.8 
-
 0.124444 2.58E+11 507633.7 
 0.132222 2.44E+11 493743.9 
@@ -22,5 +20,4 @@
 0.178889 4.41E+10 209959 
 0.186667 4.02E+10 200480.7 
-
 0.202222 5.33E+10 230891.5 
 0.21 4.99E+10 223441.9 
@@ -37,5 +34,4 @@
 0.295556 1.05E+10 102300 
 0.303333 7.95E+09 89146.17 
-
 0.334444 7.92E+09 89019.55 
 0.342222 9.75E+09 98739.25 
Index: park_integration/test/cylinder_data.txt
===================================================================
--- park_integration/test/cylinder_data.txt	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
+++ park_integration/test/cylinder_data.txt	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
@@ -0,0 +1,50 @@
+<X>   <Y>
+0.0102041  297.463
+0.0204082  152.923
+0.0306122  100.86
+0.0408163  71.2547
+0.0510204  52.0646
+0.0612245  38.8455
+0.0714286  28.9175
+0.0816327  21.3477
+0.0918367  15.585
+0.102041  11.1027
+0.112245  7.68747
+0.122449  5.14815
+0.132653  3.2721
+0.142857  1.95416
+0.153061  1.07575
+0.163265  0.514705
+0.173469  0.203241
+0.183673  0.0633005
+0.193878  0.0261093
+0.204082  0.0564741
+0.214286  0.113684
+0.22449  0.169911
+0.234694  0.217359
+0.244898  0.243473
+0.255102  0.24596
+0.265306  0.231673
+0.27551  0.20138
+0.285714  0.161839
+0.295918  0.121477
+0.306122  0.082173
+0.316327  0.0490456
+0.326531  0.0254631
+0.336735  0.00974294
+0.346939  0.00282224
+0.357143  0.00347102
+0.367347  0.00795623
+0.377551  0.0154838
+0.387755  0.0237389
+0.397959  0.0300056
+0.408163  0.0344328
+0.418367  0.0359779
+0.428571  0.0341257
+0.438776  0.0303887
+0.44898  0.0248926
+0.459184  0.018361
+0.469388  0.0124478
+0.479592  0.00720909
+0.489796  0.00321508
+0.5  0.00121297
Index: park_integration/test/test_fit_cylinder.py
===================================================================
--- park_integration/test/test_fit_cylinder.py	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
+++ park_integration/test/test_fit_cylinder.py	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
@@ -0,0 +1,48 @@
+"""
+    Unit tests for fitting module 
+"""
+import unittest
+from sans.guitools.plottables import Theory1D
+from sans.guitools.plottables import Data1D
+from sans.fit.AbstractFitEngine import Data, Model
+import math
+class testFitModule(unittest.TestCase):
+    """ test fitting """
+    def test1(self):
+        """ Fit 1 data (cyl_testdata.txt)and 1 model(CylinderModel)  """
+        #load data
+        from sans.fit.Loader import Load
+        load = Load()
+        load.set_filename("cyl_testdata.txt")
+        load.set_values()
+        data1 = Data1D(x=[], y=[],dx=None, dy=None)
+        load.load_data(data1)
+        #Importing the Fit module
+        from sans.fit.Fitting import Fit
+        fitter = Fit('scipy')
+        # Receives the type of model for the fitting
+        from sans.models.CylinderModel import CylinderModel
+        model1  = CylinderModel()
+        model1.setParam('contrast',1)
+        data = Data(sans_data=data1 )
+        model = Model(model1)
+        
+        pars1 =['length','radius','scale']
+        fitter.set_data(data,1)
+        model.model.setParam('scale',10)
+        fitter.set_model(model,"M1",1,pars1)
+        result1 = fitter.fit()
+        print "test scipy result:",result1.stderr,result1.pvec,result1.fitness
+        self.assert_(result1)
+        self.assertTrue(len(result1.pvec)>0 or len(result1.pvec)==0 )
+        self.assertTrue(len(result1.stderr)> 0 or len(result1.stderr)==0)
+        self.assertAlmostEquals( result1.pvec[0],0 )
+        self.assertAlmostEquals( result1.pvec[1],3*math.pow(10,-6) )
+        self.assertAlmostEquals( result1.pvec[2] , 1 )
+        self.assertAlmostEquals( result1.pvec[3] , 1 )
+        self.assertAlmostEquals( result1.pvec[4] , 400 )
+        self.assertAlmostEquals( result1.pvec[5] , 20 )
+        self.assertAlmostEquals ( result1.pvec[6] , 1 )
+        self.assertTrue( result1.fitness/43 < 2 )
+        
+       
Index: park_integration/test/test_fit_line.py
===================================================================
--- park_integration/test/test_fit_line.py	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
+++ park_integration/test/test_fit_line.py	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
@@ -0,0 +1,224 @@
+"""
+    Unit tests for fitting module 
+"""
+import unittest
+from sans.guitools.plottables import Theory1D
+from sans.guitools.plottables import Data1D
+from sans.fit.AbstractFitEngine import Data, Model
+import math
+class testFitModule(unittest.TestCase):
+    """ test fitting """
+    def test1(self):
+        """ Fit 1 data (testdata_line.txt)and 1 model(lineModel)  """
+        #load data
+        from sans.fit.Loader import Load
+        load = Load()
+        load.set_filename("testdata_line.txt")
+        load.set_values()
+        data1 = Data1D(x=[], y=[],dx=None, dy=None)
+        load.load_data(data1)
+        #Importing the Fit module
+        from sans.fit.Fitting import Fit
+        fitter = Fit('scipy')
+        # Receives the type of model for the fitting
+        from sans.guitools.LineModel import LineModel
+        model1  = LineModel()
+        model1.name = "M1"
+        data = Data(sans_data=data1 )
+        model = Model(model1)
+        #fit with scipy test
+        
+        pars1= ['param1','param2']
+        fitter.set_data(data,1)
+        try:fitter.set_model(model,1,pars1)
+        except ValueError,msg:
+           assert str(msg)=="wrong paramter %s used to set model %s. Choose\
+                            parameter name within %s"%('param1', model.model.name,str(model.model.getParamList()))
+        else: raise AssertError,"No error raised for scipy fitting with wrong parameters name to fit"
+        pars1= ['A','B']
+        fitter.set_model(model,1,pars1)
+        result1 = fitter.fit()
+        self.assert_(result1)
+        
+        self.assertTrue( ( math.fabs(result1.pvec[0]-4)/3 == result1.stderr[0] ) or 
+                         ( math.fabs(result1.pvec[0]-4)/3 < result1.stderr[0]) ) 
+        
+        self.assertTrue( ( math.fabs(result1.pvec[1]-2.5)/3 == result1.stderr[1]) or
+                         ( math.fabs(result1.pvec[1]-2.5)/3 < result1.stderr[1] ) )
+        self.assertTrue( result1.fitness/49 < 2 )
+        
+        #fit with park test
+        fitter = Fit('park')
+        fitter.set_data(data,1)
+        fitter.set_model(model,1,pars1)
+        result2 = fitter.fit()
+        
+        self.assert_(result2)
+        
+        self.assertTrue( ( math.fabs(result2.pvec[0]-4)/3 == result2.stderr[0] ) or 
+                         ( math.fabs(result2.pvec[0]-4)/3 < result2.stderr[0]) ) 
+        
+        self.assertTrue( ( math.fabs(result2.pvec[1]-2.5)/3 == result2.stderr[1] ) or
+                         ( math.fabs(result2.pvec[1]-2.5)/3 < result2.stderr[1]) )
+        self.assertTrue(result2.fitness/49 < 2)
+        # compare fit result result for scipy and park
+        self.assertAlmostEquals( result1.pvec[0], result2.pvec[0] )
+        self.assertAlmostEquals( result1.pvec[1],result2.pvec[1] )
+        self.assertAlmostEquals( result1.stderr[0],result2.stderr[0] )
+        self.assertAlmostEquals( result1.stderr[1],result2.stderr[1] )
+        self.assertAlmostEquals( result1.fitness,result2.fitness )
+        
+    def test2(self):
+        """ fit 2 data and 2 model with no constrainst"""
+        #load data
+        from DataLoader.loader import Loader
+        l = Loader()
+        out=l.load("testdata_line.txt")
+        data11 = Data1D(x=out.x, y=out.y, dx=out.dx, dy=out.y)
+        out=l.load("testdata_line1.txt")
+        data22 = Data1D(x=out.x, y=out.y, dx=out.dx, dy=out.y)
+        #Importing the Fit module
+        from sans.fit.Fitting import Fit
+        fitter = Fit('scipy')
+        # Receives the type of model for the fitting
+        from sans.guitools.LineModel import LineModel
+        model11  = LineModel()
+        model11.name= "M1"
+        model22  = LineModel()
+        model11.name= "M2"
+        data1 = Data(sans_data=data11 )
+        data2 = Data(sans_data=data22 )
+        model1 = Model(model11)
+        model2 = Model(model22)
+        #fit with scipy test
+        pars1= ['A','B']
+        fitter.set_data(data1,1)
+        fitter.set_model(model1,1,pars1)
+        fitter.set_data(data2,2)
+        fitter.set_model(model2,2,pars1)
+        try: result1 = fitter.fit()
+        except RuntimeError,msg:
+           assert str(msg)=="Scipy can't fit more than a single fit problem at a time."
+        else: raise AssertError,"No error raised for scipy fitting with more than 2 models"
+        
+        #fit with park test
+        fitter = Fit('park')
+        fitter.set_data(data1,1)
+        fitter.set_model(model1,1,pars1)
+        fitter.set_data(data2,2)
+        fitter.set_model(model2,2,pars1)
+        result2 = fitter.fit()
+        
+        self.assert_(result2)
+        self.assertTrue( ( math.fabs(result2.pvec[0]-4)/3 == result2.stderr[0] ) or 
+                         ( math.fabs(result2.pvec[0]-4)/3 < result2.stderr[0]) ) 
+        
+        self.assertTrue( ( math.fabs(result2.pvec[1]-2.5)/3 == result2.stderr[1] ) or
+                         ( math.fabs(result2.pvec[1]-2.5)/3 < result2.stderr[1]) )
+        self.assertTrue(result2.fitness/49 < 2)
+        
+        
+    def test3(self):
+        """ fit 2 data and 2 model with 1 constrainst"""
+        #load data
+        from DataLoader.loader import Loader
+        l = Loader()
+        out=l.load("testdata_line.txt")
+        data11 = Data1D(x=out.x, y=out.y, dx=out.dx, dy=out.y)
+        out=l.load("testdata_cst.txt")
+        data22 = Data1D(x=out.x, y=out.y, dx=out.dx, dy=out.y)
+        #Importing the Fit module
+        from sans.fit.Fitting import Fit
+        fitter = Fit('park')
+        # Receives the type of model for the fitting
+        from sans.guitools.LineModel import LineModel
+        from sans.models.Constant import Constant
+        model11  = LineModel()
+        model11.name= "line"
+        model22  = Constant()
+        model22.name= "cst"
+        model22.setParam('value','line.A')
+        
+        data1 = Data(sans_data=data11 )
+        data2 = Data(sans_data=data22 )
+        model1 = Model(model11)
+        model2 = Model(model22)
+        #fit with scipy test
+        pars1= ['A','B']
+        pars2= ['value']
+        
+        fitter.set_data(data1,1)
+        fitter.set_model(model1,1,pars1)
+        fitter.set_data(data2,2)
+        fitter.set_model(model2,2,pars2)
+        
+        result2 = fitter.fit()
+        self.assert_(result2)
+        self.assertTrue( ( math.fabs(result2.pvec[0]-4)/3 == result2.stderr[0] ) or 
+                         ( math.fabs(result2.pvec[0]-4)/3 < result2.stderr[0]) ) 
+        
+        self.assertTrue( ( math.fabs(result2.pvec[1]-2.5)/3 == result2.stderr[1] ) or
+                         ( math.fabs(result2.pvec[1]-2.5)/3 < result2.stderr[1]) )
+        self.assertTrue(result2.fitness/49 < 2)
+        
+        
+    def test4(self):
+        """ fit 2 data concatenates with limited range of x and  one model """
+            #load data
+        from DataLoader.loader import Loader
+        l = Loader()
+        out=l.load("testdata_line.txt")
+        data11 = Data1D(x=out.x, y=out.y, dx=out.dx, dy=out.y)
+        out=l.load("testdata_line1.txt")
+        data22 = Data1D(x=out.x, y=out.y, dx=out.dx, dy=out.y)
+        #Importing the Fit module
+        from sans.fit.Fitting import Fit
+        fitter = Fit('scipy')
+        # Receives the type of model for the fitting
+        from sans.guitools.LineModel import LineModel
+        model1  = LineModel()
+        model1.name= "M1"
+        
+        data1 = Data(sans_data=data11 )
+        data2 = Data(sans_data=data22 )
+        model = Model(model1)
+        
+        #fit with scipy test
+        pars1= ['A','B']
+        fitter.set_data(data1,1,qmin=0, qmax=7)
+        fitter.set_model(model,1,pars1)
+        fitter.set_data(data2,1,qmin=1,qmax=10)
+        
+        result1 = fitter.fit()
+        self.assert_(result1)
+        
+        self.assertTrue( ( math.fabs(result1.pvec[0]-4)/3 == result1.stderr[0] ) or 
+                         ( math.fabs(result1.pvec[0]-4)/3 < result1.stderr[0]) ) 
+        
+        self.assertTrue( ( math.fabs(result1.pvec[1]-2.5)/3 == result1.stderr[1]) or
+                         ( math.fabs(result1.pvec[1]-2.5)/3 < result1.stderr[1] ) )
+        self.assertTrue( result1.fitness/49 < 2 )
+        
+        
+        #fit with park test
+        fitter = Fit('park')
+        fitter.set_data(data1,1,qmin=0, qmax=7)
+        fitter.set_model(model,1,pars1)
+        fitter.set_data(data2,1,qmin=1,qmax=10)
+       
+        result2 = fitter.fit()
+        
+        self.assert_(result2)
+        self.assertTrue( ( math.fabs(result2.pvec[0]-4)/3 == result2.stderr[0] ) or 
+                         ( math.fabs(result2.pvec[0]-4)/3 < result2.stderr[0]) ) 
+        
+        self.assertTrue( ( math.fabs(result2.pvec[1]-2.5)/3 == result2.stderr[1] ) or
+                         ( math.fabs(result2.pvec[1]-2.5)/3 < result2.stderr[1]) )
+        self.assertTrue(result2.fitness/49 < 2)
+        # compare fit result result for scipy and park
+        self.assertAlmostEquals( result1.pvec[0], result2.pvec[0] )
+        self.assertAlmostEquals( result1.pvec[1],result2.pvec[1] )
+        self.assertAlmostEquals( result1.stderr[0],result2.stderr[0] )
+        self.assertAlmostEquals( result1.stderr[1],result2.stderr[1] )
+        self.assertAlmostEquals( result1.fitness,result2.fitness )
+    
Index: rk_integration/test/testdata1.txt
===================================================================
--- park_integration/test/testdata1.txt	(revision 792db7d542f8814e2fad10b22652d74f24c7e14f)
+++ 	(revision )
@@ -1,16 +1,0 @@
-0  2.83954  0.6
-0.204082  3.44938  0.676531
-0.408163  5.82026  0.753061
-0.612245  5.27591  0.829592
-0.816327  5.2781  0.906122
-1.02041  5.22531  0.982653
-1.22449  7.47487  1.05918
-1.42857  7.85852  1.13571
-1.63265  10.2278  1.21224
-1.83673  8.33195  1.28878
-2.04082  9.22407  1.36531
-2.2449  7.95013  1.44184
-2.44898  10.0289  1.51837
-2.65306  11.0736  1.5949
-2.85714  12.2957  1.67143
-3.06122  12.3108  1.74796
Index: rk_integration/test/testdata2.txt
===================================================================
--- park_integration/test/testdata2.txt	(revision 792db7d542f8814e2fad10b22652d74f24c7e14f)
+++ 	(revision )
@@ -1,15 +1,0 @@
-3.26531  12.6916  1.82449
-3.46939  12.5859  1.90102
-3.67347  14.5972  1.97755
-3.87755  10.9443  2.05408
-4.08163  11.4356  2.13061
-4.28571  19.3213  2.20714
-4.4898  14.3191  2.28367
-4.69388  14.6961  2.3602
-4.89796  19.27  2.43673
-5.10204  12.1831  2.51327
-5.30612  21.4745  2.5898
-5.5102  20.0393  2.66633
-5.71429  13.2472  2.74286
-5.91837  14.9428  2.81939
-6.12245  22.1974  2.89592
Index: park_integration/test/testdata_line.txt
===================================================================
--- park_integration/test/testdata_line.txt	(revision 6b126e8c0609d8c6835c7d3cc15aa30f50dfd05d)
+++ park_integration/test/testdata_line.txt	(revision ca6d9147f03c7552f57ffed23847f9b690a7af14)
@@ -1,5 +1,5 @@
-#y=A*x+B
-#A=2.5
-#B=4
+#y=A+x*B
+#B=2.5
+#A=4
 0  2.83954  0.6
 0.204082  3.44938  0.676531
Index: rk_integration/test/testfitting.py
===================================================================
--- park_integration/test/testfitting.py	(revision 48882d14c03b61d8a22b600abadcccba552c8697)
+++ 	(revision )
@@ -1,147 +1,0 @@
-"""
-    Unit tests for fitting module 
-"""
-import unittest
-from sans.guitools.plottables import Theory1D
-from sans.guitools.plottables import Data1D
-from sans.fit.AbstractFitEngine import Data, Model
-import math
-class testFitModule(unittest.TestCase):
-    """ test fitting """
-    def testLoader(self):
-        """ 
-            test module Load
-        """
-        from sans.fit.Loader import Load
-        load= Load()
-        load.set_filename("testdata_line.txt")
-        self.assertEqual(load.get_filename(),"testdata_line.txt")
-        load.set_values()
-        x=[]
-        y=[]
-        dx=[]
-        dy=[]
-        x,y,dx,dy = load.get_values()
-        # test that values have been loaded
-        self.assertNotEqual(x, None)
-        self.assertNotEqual(y, [])
-        self.assertNotEqual(dy, None)
-        self.assertEqual(len(x),len(y))
-        self.assertEqual(len(dy),len(y))
-        
-        # test data the two plottables contained values loaded
-        data1 = Theory1D(x=[], y=[], dy=None)
-        data2 = Data1D(x=[], y=[],dx=None, dy=None)
-        data1.name = "data1"
-        data2.name = "data2"
-        load.load_data(data1)
-        load.load_data(data2)
-        
-        
-        for i in range(len(x)):
-            self.assertEqual(data2.x[i],x[i])
-            self.assertEqual(data1.y[i],y[i])
-            self.assertEqual(data2.y[i],y[i])
-            self.assertEqual(data1.dx[i],dx[i])
-            self.assertEqual(data2.dy[i],dy[i])
-            self.assertEqual(data1.x[i],data2.x[i])
-            self.assertEqual(data2.y[i],data2.y[i])
-            
-           
-    def testfit_1Data_1Model(self):
-        """ test fitting for one data and one model park vs scipy"""
-        #load data
-        from sans.fit.Loader import Load
-        load= Load()
-        load.set_filename("testdata_line.txt")
-        load.set_values()
-        data11 = Data1D(x=[], y=[],dx=None, dy=None)
-        load.load_data(data11)
-        
-        #Importing the Fit module
-        from sans.fit.Fitting import Fit
-        fitter= Fit('scipy')
-        
-        # Receives the type of model for the fitting
-        from sans.guitools.LineModel import LineModel
-        model11  = LineModel()
-        model22  = LineModel()
-        
-        #Do the fit SCIPY
-        model11.setParam( 'A', 2)
-        model11.setParam( 'B', 1)
-        data1=Data(sans_data=data11)
-        model1 =Model(model11)
-        model2 =Model(model22)
-      
-        fitter.set_data(data1,1)
-        fitter.set_model(model1,"M1",1,['A','B'])
-        
-        result= fitter.fit()
-        out1=result.pvec
-        chisqr1=result.fitness
-        cov1=result.cov
-        print "scipy",chisqr1, out1, cov1
-        """ testing SCIPy results"""
-        self.assert_(math.fabs(out1[1]-2.5)/math.sqrt(cov1[1][1]) < 2)
-        self.assert_(math.fabs(out1[0]-4.0)/math.sqrt(cov1[0][0]) < 2)
-        self.assert_(chisqr1/len(data1.x) < 2)
-        # PARK
-        fitter= Fit('park')
-        
-        #Do the fit
-        fitter.set_data(data1,1)
-        model2.setParams( [2,1])
-    
-        fitter.set_model(model2,"M1",1,['A','B'])
-       
-        result2=fitter.fit(None,None)
-        out2=result2.pvec
-        chisqr2=result2.fitness
-        cov2=result2.cov
-        self.assert_(math.fabs(out2[1]-2.5)/math.sqrt(cov2[1][1]) < 2)
-        self.assert_(math.fabs(out2[0]-4.0)/math.sqrt(cov2[0][0]) < 2)
-        self.assert_(chisqr2/len(data1.x) < 2)
-        print "scipy",chisqr1, out1, cov1
-        print "park",chisqr2, out2, cov2
-        self.assertAlmostEquals(out1[1], out2[1],0)
-        self.assertAlmostEquals(out1[0], out2[0],0)
-        self.assertAlmostEquals(cov1[0][0], cov2[0][0],1)
-        self.assertAlmostEquals(cov1[1][1], cov2[1][1],1)
-        self.assertAlmostEquals(chisqr1, chisqr2)
-         
-    def testfit_1Data_1Model(self):
-        """ test fitting for one data and one model cipy"""
-        #load data
-        from sans.fit.Loader import Load
-        load= Load()
-        load.set_filename("testdata_line.txt")
-        load.set_values()
-        data11 = Data1D(x=[], y=[],dx=None, dy=None)
-        load.load_data(data11)
-        data1=Data(sans_data=data11)
-    
-        #Importing the Fit module
-        from sans.fit.Fitting import Fit
-        fitter= Fit('scipy')
-        
-        # Receives the type of model for the fitting
-        from sans.guitools.LineModel import LineModel
-        model1  = LineModel()
-        model =Model(model1)
-        
-        #Do the fit SCIPY
-        fitter.set_data(data1,1)
-        import math
-       
-        pars1=['A','B']
-        pars1.sort()
-        fitter.set_model(model,"M1",1,pars1)
-        result=fitter.fit()
-        print "scipy",result.fitness,result.cov, result.pvec
-    
-        self.assert_(result.fitness)
-        
-       
-    
-      
Index: rk_integration/test/testnewscipy.py
===================================================================
--- park_integration/test/testnewscipy.py	(revision fa5908de52958be4caa55a3ad90f523b19db6d4a)
+++ 	(revision )
@@ -1,77 +1,0 @@
-"""
-    Unit tests for fitting module 
-"""
-import unittest
-from sans.guitools.plottables import Theory1D
-from sans.guitools.plottables import Data1D
-from sans.fit.AbstractFitEngine import Data, Model
-import math
-class testFitModule(unittest.TestCase):
-    """ test fitting """
-    
-    def testfit_1Data_1Model(self):
-        """ test fitting for one data and one model park vs scipy"""
-        #load data
-        from sans.fit.Loader import Load
-        load= Load()
-        load.set_filename("cyl_testdata.txt")
-        load.set_values()
-        data11 = Data1D(x=[], y=[],dx=None, dy=None)
-        load.load_data(data11)
-        
-        #Importing the Fit module
-        from sans.fit.Fitting import Fit
-        fitter= Fit('park')
-        
-        # Receives the type of model for the fitting
-        from sans.models.Lorentzian import Lorentzian
-        model1  = Lorentzian()
-        data1=Data(sans_data=data11)
-        model =Model(model1)
-        #Do the fit SCIPY
-        pars1=['center','gamma','scale']
-        fitter.set_data(data1,1)
-        fitter.set_model(model,"M1",1,pars1)
-        
-        result=fitter.fit()
-        print "park1",result.pvec,result.fitness,result.cov
-        
-        self.assert_(result)
-      
-    def test_cylinder_scipy(self):
-        """ test fitting large model with scipy"""
-        #load data
-        from sans.fit.Loader import Load
-        load= Load()
-        load.set_filename("cyl_testdata.txt")
-        load.set_values()
-        data11 = Data1D(x=[], y=[],dx=None, dy=None)
-        load.load_data(data11)
-        data1=Data(sans_data=data11)
-        
-        
-        #Importing the Fit module
-        from sans.fit.Fitting import Fit
-        fitter= Fit('park')
-        
-        # Receives the type of model for the fitting
-        from sans.models.CylinderModel import CylinderModel
-        model1  = CylinderModel()
-        model =Model(model1)
-        
-        #Do the fit SCIPY
-        fitter.set_data(data1,1)
-        import math
-        pars1=['background','contrast', 'length']
-        #pars1=['background','contrast',\
-        #        'cyl_phi','cyl_theta','length','radius','scale']
-        pars1.sort()
-        fitter.set_model(model,"M1",1,pars1)
-        fitter.set_data(data1,1)
-      
-        result=fitter.fit()
-        print "park2",result.fitness,result.cov, result.pvec
-        self.assert_(result.fitness)
-        
-    
-      
