Index: park_integration/.pydevproject
===================================================================
--- park_integration/.pydevproject	(revision 4408fb07d14aa7b89d775dfbb9b00f759a33db73)
+++ park_integration/.pydevproject	(revision 9e857929197322ca949a60c6dc66670d05725dcc)
@@ -4,5 +4,5 @@
 <pydev_project>
 <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
-<path>/park_integration 3/src</path>
+<path>/park_integration/src</path>
 </pydev_pathproperty>
 <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.5</pydev_property>
Index: park_integration/ParkFitting.py
===================================================================
--- park_integration/ParkFitting.py	(revision 4408fb07d14aa7b89d775dfbb9b00f759a33db73)
+++ park_integration/ParkFitting.py	(revision 9e857929197322ca949a60c6dc66670d05725dcc)
@@ -11,5 +11,5 @@
 #from sans.guitools import plottables
 from Loader import Load
-
+from park import expression
 class SansParameter(park.Parameter):
     """
@@ -20,6 +20,10 @@
     def __init__(self, name, model):
          self._model, self._name = model,name
+         self.set(model.getParam(name))
     def _getvalue(self): return self._model.getParam(self.name)
-    def _setvalue(self,value): self._model.setParam(self.name, value)
+    def _setvalue(self,value): 
+        if numpy.isnan(value):
+            print "setting %s.%s to"%(self._model.name,self.name),value
+        self._model.setParam(self.name, value)
     value = property(_getvalue,_setvalue)
     def _getrange(self):
@@ -130,22 +134,28 @@
         """
         mylist=[]
+        listmodel=[]
         for k,value in self.fitArrangeList.iteritems():
-            couple=()
-            model=value.get_model()
-            parameters= self.set_param(model, pars)
-            model = Model(model)
+            #couple=()
+            sansmodel=value.get_model()
+           
+            #parameters= self.set_param(model,model.name, pars)
+            parkmodel = Model(sansmodel)
             #print "model created",model.parameterset[0].value,model.parameterset[1].value
             # Make all parameters fitting parameters
-            for p in model.parameterset:
-                p.set([-numpy.inf,numpy.inf])
-                #p.set([-10,10])
+            
+            
+            for p in parkmodel.parameterset:
+                #p.range([-numpy.inf,numpy.inf])
+                # Convert parameters with initial values into fitted parameters
+                # spanning all possible values.  Parameters which are expressions
+                # will remain as expressions.
+                if p.isfixed():
+                    p.set([-numpy.inf,numpy.inf])
+                
             Ldata=value.get_data()
             data=self._concatenateData(Ldata)
-            #print "this data",data
-            #print "data.residuals in createProblem",Ldata[0].residuals
-            #print "data.residuals in createProblem",data.residuals
-            #couple1=(model,Ldata[0])
-            #mylist.append(couple1)
-            couple=(model,data)
+            data1=Data(data)
+           
+            couple=(parkmodel,data1)
             mylist.append(couple)
         #print mylist
@@ -153,19 +163,22 @@
         #return model,data
     
-    def fit(self,pars, qmin=None, qmax=None):
+    def fit(self,pars=None, qmin=None, qmax=None):
         """
              Do the fit 
         """
-        
-        modelList=self.createProblem(pars)
-        #model,data=self.createProblem()
-        #fitness=assembly.Fitness(model,data)
-        
+    
+        print "starting ParkFit.fit()"
+        modelList=self.createProblem()
         problem =  park.Assembly(modelList)
-        print "problem :",problem[0].parameterset,problem[0].parameterset.fitted
+        pars=problem.fit_parameters()
+        print "About to call eval",pars
+        print "initial",[p.value for p in pars]
+        problem.eval()
+        #print "M2.B",problem.parameterset['M2.B'].expression,problem.parameterset['M2.B'].value
+        #print "problem :",problem[0].parameterset,problem[0].parameterset.fitted
+        
         #problem[0].parameterset['A'].set([0,1000])
         #print "problem :",problem[0].parameterset,problem[0].parameterset.fitted
         fit.fit(problem, handler= fitresult.ConsoleUpdate(improvement_delta=0.1))
-        #fit.fit(problem, handler= fitresult.ConsoleUpdate(improvement_delta=0.1))
        
     
@@ -182,5 +195,5 @@
     def set_data(self,data,Uid):
         """ Receive plottable and create a list of data to fit"""
-        data=Data(data)
+        
         if self.fitArrangeList.has_key(Uid):
             self.fitArrangeList[Uid].add_data(data)
@@ -194,5 +207,5 @@
         return self.fitArrangeList[Uid]
     
-    def set_param(self,model, pars):
+    def set_param(self,model,name, pars):
         """ Recieve a dictionary of parameter and save it """
         parameters=[]
@@ -200,5 +213,5 @@
             raise ValueError, "Cannot set parameters for empty model"
         else:
-            #for key ,value in pars:
+            model.name=name
             for key, value in pars.iteritems():
                 param = Parameter(model, key, value)
Index: park_integration/test/constrainttestpark.py
===================================================================
--- park_integration/test/constrainttestpark.py	(revision 9e857929197322ca949a60c6dc66670d05725dcc)
+++ park_integration/test/constrainttestpark.py	(revision 9e857929197322ca949a60c6dc66670d05725dcc)
@@ -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.ScipyFitting import Parameter
+import math
+class testFitModule(unittest.TestCase):
+    
+    def test2models2dataonconstraint(self):
+        """ test fitting for two set of data  and one model with a constraint"""
+        from sans.fit.Loader import Load
+        load= Load()
+        #Load the first set of data
+        load.set_filename("testdata1.txt")
+        load.set_values()
+        data1 = Data1D(x=[], y=[],dx=None, dy=None)
+        load.load_data(data1)
+        
+        #Load the second set of data
+        load.set_filename("testdata2.txt")
+        load.set_values()
+        data2 = Data1D(x=[], y=[],dx=None, dy=None)
+        load.load_data(data2)
+        
+        #Importing the Fit module
+        from sans.fit.Fitting import Fit
+        fitter= Fit()
+        # Receives the type of model for the fitting
+        from sans.guitools.LineModel import LineModel
+        model1  = LineModel()
+        model2  = LineModel()
+        #set engine for scipy 
+        fitter.fit_engine('park')
+        engine = fitter.returnEngine()
+        #Do the fit
+        engine.set_param( model1,"M1", {'A':2,'B':3})
+        engine.set_model(model1,1)
+        engine.set_data(data1,1)
+        #print "m1 param b", M1.B
+        engine.set_param( model2,"M2", {'A':1,'B':'2*M1.B'})
+        engine.set_model(model2,2)
+        engine.set_data(data2,2)
+    
+        
+        print engine.fit({'A':2,'B':1},None,None)
+      
Index: park_integration/test/testfitting.py
===================================================================
--- park_integration/test/testfitting.py	(revision 770530690a37496a90d89a41d399cc96206e8f8d)
+++ park_integration/test/testfitting.py	(revision 9e857929197322ca949a60c6dc66670d05725dcc)
@@ -165,2 +165,54 @@
             self.assertEqual(cov1[1][1],cov2[1][1])
         """
+    def test2models2dataonconstraint(self):
+        """ test for 2 Models two data one constraint"""
+        from sans.fit.Loader import Load
+        load= Load()
+        #Load the first set of data
+        load.set_filename("testdata1.txt")
+        load.set_values()
+        data1 = Data1D(x=[], y=[],dx=None, dy=None)
+        load.load_data(data1)
+        
+        #Load the second set of data
+        load.set_filename("testdata2.txt")
+        load.set_values()
+        data2 = Data1D(x=[], y=[],dx=None, dy=None)
+        load.load_data(data2)
+       
+        #Importing the Fit module
+        from sans.fit.Fitting import Fit
+        fitter= Fit()
+        # Receives the type of model for the fitting
+        from sans.guitools.LineModel import LineModel
+        model1  = LineModel()
+        model1.name='M1'
+        model2  = LineModel()
+        model2.name='M2'
+        #set engine for scipy 
+        fitter.fit_engine('scipy')
+        engine = fitter.returnEngine()
+        #Do the fit
+        engine.set_model(model1,1)
+        engine.set_data(data1,1)
+        engine.set_model(model2,2)
+        engine.set_data(data2,2)
+    
+        try: engine.fit({'A':2,'B':1},None,None)
+        except ValueError,msg:
+            assert str(msg)=="cannot fit more than one model",'Message: <%s>'%(msg)
+        
+        #set engine for park 
+        fitter= Fit()
+        fitter.fit_engine('park')
+        engine = fitter.returnEngine()
+        #Do the fit
+        engine.set_data(data1,1)
+        engine.set_param(model1,{'A':2,'B':1})
+        engine.set_model(model1,1)
+        
+        engine.set_param(model2,{'A':3,'B':'5*M1.B'})
+        engine.set_model(model2,2)
+        engine.set_data(data2,2)
+        engine.fit({'A':2,'B':1},None,None)
+        
Index: park_integration/test/testpark.py
===================================================================
--- park_integration/test/testpark.py	(revision 9e857929197322ca949a60c6dc66670d05725dcc)
+++ park_integration/test/testpark.py	(revision 9e857929197322ca949a60c6dc66670d05725dcc)
@@ -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.ScipyFitting import Parameter
+import math
+class testFitModule(unittest.TestCase):
+    
+    def test2models2dataonconstraint(self):
+        """ test fitting for two set of data  and one model"""
+        from sans.fit.Loader import Load
+        load= Load()
+        #Load the first set of data
+        load.set_filename("testdata1.txt")
+        load.set_values()
+        data1 = Data1D(x=[], y=[],dx=None, dy=None)
+        load.load_data(data1)
+        
+        #Load the second set of data
+        load.set_filename("testdata2.txt")
+        load.set_values()
+        data2 = Data1D(x=[], y=[],dx=None, dy=None)
+        load.load_data(data2)
+        
+        #Importing the Fit module
+        from sans.fit.Fitting import Fit
+        fitter= Fit()
+        # Receives the type of model for the fitting
+        from sans.guitools.LineModel import LineModel
+        model1  = LineModel()
+        model2  = LineModel()
+        #set engine for scipy 
+        fitter.fit_engine('park')
+        engine = fitter.returnEngine()
+        #Do the fit
+        engine.set_param( model1,"M1", {'A':2.5,'B':4})
+        engine.set_model(model1,1)
+        engine.set_data(data1,1)
+        
+        engine.set_param( model2,"M2", {'A':2.5,'B':4})
+        engine.set_model(model2,2)
+        engine.set_data(data2,2)
+    
+        
+        print engine.fit({'A':2,'B':1},None,None)
+      
