Index: src/sas/sasgui/perspectives/fitting/fitproblem.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/fitproblem.py	(revision 50fcb09b3ee47cf23c26b90d9c291f41415c0aa5)
+++ src/sas/sasgui/perspectives/fitting/fitproblem.py	(revision 251ef68424c8f373dfb82af3c159086491c5f975)
@@ -17,10 +17,40 @@
 from sas.sascalc.fit.qsmearing import smear_selection
 
-class FitProblemComponent(object):
+class FitProblem(object):
     """
-    Inferface containing information to store data, model, range of data, etc...
-    and retreive this information. This is an inferface
-    for a fitProblem i.e relationship between data and model.
+    Define the relationship between data and model, including range, weights,
+    etc.
     """
+    def __init__(self):
+        """
+        contains information about data and model to fit
+        """
+        ## data used for fitting
+        self.fit_data = None
+        self.theory_data = None
+        self.residuals = None
+        # original data: should not be modified
+        self.original_data = None
+        ## the current model
+        self.model = None
+        ## if 1 this fit problem will be selected to fit , if 0
+        ## it will not be selected for fit
+        self.schedule = 0
+        ##list containing parameter name and value
+        self.list_param = []
+        self.list_param2fit = []
+        ## smear object to smear or not data1D
+        self.smearer_computed = False
+        self.smearer_enable = False
+        self.smearer_computer_value = None
+        ## fitting range
+        self.qmin = None
+        self.qmax = None
+        # fit weight
+        self.weight = None
+        self.result = None
+        self.fit_tab_caption = None
+        self.name_per_page = None
+
     def enable_smearing(self, flag=False):
         """
@@ -28,4 +58,14 @@
             flag is 0 ingore smear value.
         """
+        self.smearer_enable = flag
+
+    def set_smearer(self, smearer):
+        """
+        save reference of  smear object on fitdata
+
+        :param smear: smear object from DataLoader
+
+        """
+        self.smearer_computer_value = smearer
 
     def get_smearer(self):
@@ -33,11 +73,22 @@
         return smear object
         """
+        if not self.smearer_enable:
+            return None
+        if not self.smearer_computed:
+            #smeari_selection should be call only once per fitproblem
+            self.smearer_computer_value = smear_selection(self.fit_data,
+                                                          self.model)
+            self.smearer_computed = True
+        return self.smearer_computer_value
+
     def save_model_name(self, name):
         """
         """
+        self.name_per_page = name
 
     def get_name(self):
         """
         """
+        return self.name_per_page
 
     def set_model(self, model):
@@ -47,4 +98,8 @@
         :param name: name created for model
         """
+        self.model = model
+        self.smearer_computer_value = smear_selection(self.fit_data,
+                                                      self.model)
+        self.smearer_computed = True
 
     def get_model(self):
@@ -52,4 +107,5 @@
         :return: saved model
         """
+        return self.model
 
     def set_residuals(self, residuals):
@@ -58,4 +114,5 @@
         :param data: data selected
         """
+        self.residuals = residuals
 
     def get_residuals(self):
@@ -63,27 +120,79 @@
         :return: residuals
         """
+        return self.residuals
 
     def set_theory_data(self, data):
         """
         save a copy of the data select to fit
+
         :param data: data selected
-        """
+
+        """
+        self.theory_data = copy.deepcopy(data)
 
     def get_theory_data(self):
         """
-        :return: list of data dList
-        """
+        :return: theory generated with the current model and data of this class
+        """
+        return self.theory_data
 
     def set_fit_data(self, data):
         """
-        Store of list of data and create  by create new fitproblem of each data
-        id, if there was existing information about model, this information
-        get copy to the new fitproblem
+        Store data associated with this class
         :param data: list of data selected
         """
+        self.original_data = None
+        self.fit_data = None
+        # original data: should not be modified
+        self.original_data = data
+        # fit data: used for fit and can be modified for convenience
+        self.fit_data = copy.deepcopy(data)
+        self.smearer_computer_value = smear_selection(self.fit_data, self.model)
+        self.smearer_computed = True
+        self.result = None
 
     def get_fit_data(self):
         """
-        """
+        :return: data associate with this class
+        """
+        return self.fit_data
+
+    def get_origin_data(self):
+        """
+        """
+        return self.original_data
+
+    def set_weight(self, is2d, flag=None):
+        """
+        Received flag and compute error on data.
+        :param flag: flag to transform error of data.
+        :param is2d: flag to distinguish 1D to 2D Data
+        """
+        from sas.sasgui.perspectives.fitting.utils import get_weight
+        # send original data for weighting
+        self.weight = get_weight(data=self.original_data, is2d=is2d, flag=flag)
+        if is2d:
+            self.fit_data.err_data = self.weight
+        else:
+            self.fit_data.dy = self.weight
+
+    def get_weight(self):
+        """
+        returns weight array
+        """
+        return self.weight
+
+    def set_param2fit(self, list):
+        """
+        Store param names to fit (checked)
+        :param list: list of the param names
+        """
+        self.list_param2fit = list
+
+    def get_param2fit(self):
+        """
+        return the list param names to fit
+        """
+        return self.list_param2fit
 
     def set_model_param(self, name, value=None):
@@ -93,15 +202,5 @@
         :param value: value of that parameter
         """
-
-    def set_param2fit(self, list):
-        """
-        Store param names to fit (checked)
-        :param list: list of the param names
-        """
-
-    def get_param2fit(self):
-        """
-        return the list param names to fit
-        """
+        self.list_param.append([name, value])
 
     def get_model_param(self):
@@ -109,4 +208,5 @@
         return list of couple of parameter name and value
         """
+        return self.list_param
 
     def schedule_tofit(self, schedule=0):
@@ -114,4 +214,5 @@
         set schedule to true to decide if this fit  must be performed
         """
+        self.schedule = schedule
 
     def get_scheduled(self):
@@ -119,24 +220,21 @@
         return true or false if a problem as being schedule for fitting
         """
+        return self.schedule
 
     def set_range(self, qmin=None, qmax=None):
         """
         set fitting range
-        """
+        :param qmin: minimum value to consider for the fit range
+        :param qmax: maximum value to consider for the fit range
+        """
+        self.qmin = qmin
+        self.qmax = qmax
 
     def get_range(self):
         """
         :return: fitting range
-        """
-
-    def set_weight(self, flag=None):
-        """
-        set fitting range
-        """
-
-    def get_weight(self):
-        """
-        get fitting weight
-        """
+
+        """
+        return self.qmin, self.qmax
 
     def clear_model_param(self):
@@ -144,14 +242,15 @@
         clear constraint info
         """
+        self.list_param = []
 
     def set_fit_tab_caption(self, caption):
         """
-        store the caption of the page associated with object
-        """
+        """
+        self.fit_tab_caption = str(caption)
 
     def get_fit_tab_caption(self):
         """
-        Return the caption of the page associated with object
-        """
+        """
+        return self.fit_tab_caption
 
     def set_graph_id(self, id):
@@ -159,4 +258,5 @@
         Set graph id (from data_group_id at the time the graph produced)
         """
+        self.graph_id = id
 
     def get_graph_id(self):
@@ -164,8 +264,10 @@
         Get graph_id
         """
+        return self.graph_id
 
     def set_result(self, result):
         """
         """
+        self.result = result
 
     def get_result(self):
@@ -173,12 +275,12 @@
         get result
         """
-
-
-class FitProblemDictionary(FitProblemComponent, dict):
+        return self.result
+
+
+class FitProblemDictionary(dict):
     """
     This module implements a dictionary of fitproblem objects
     """
     def __init__(self):
-        FitProblemComponent.__init__(self)
         dict.__init__(self)
         ## the current model
@@ -207,9 +309,8 @@
         self._smear_on = flag
         if fid is None:
-            for value in self.itervalues():
+            for value in self.values():
                 value.enable_smearing(flag)
-        else:
-            if fid in self.iterkeys():
-                self[fid].enable_smearing(flag)
+        elif fid in self:
+            self[fid].enable_smearing(flag)
 
     def set_smearer(self, smearer, fid=None):
@@ -219,9 +320,8 @@
         """
         if fid is None:
-            for value in self.itervalues():
+            for value in self.values():
                 value.set_smearer(smearer)
-        else:
-            if fid in self.iterkeys():
-                self[fid].set_smearer(smearer)
+        elif fid in self:
+            self[fid].set_smearer(smearer)
 
     def get_smearer(self, fid=None):
@@ -229,5 +329,5 @@
         return smear object
         """
-        if fid in self.iterkeys():
+        if fid in self:
             return self[fid].get_smearer()
 
@@ -236,9 +336,8 @@
         """
         if fid is None:
-            for value in self.itervalues():
+            for value in self.values():
                 value.save_model_name(name)
-        else:
-            if fid in self.iterkeys():
-                self[fid].save_model_name(name)
+        elif fid in self:
+            self[fid].save_model_name(name)
 
     def get_name(self, fid=None):
@@ -247,9 +346,8 @@
         result = []
         if fid is None:
-            for value in self.itervalues():
+            for value in self.values():
                 result.append(value.get_name())
-        else:
-            if fid in self.iterkeys():
-                result.append(self[fid].get_name())
+        elif fid in self:
+            result.append(self[fid].get_name())
         return result
 
@@ -262,9 +360,8 @@
         self.model = model
         if fid is None:
-            for value in self.itervalues():
+            for value in self.values():
                 value.set_model(self.model)
-        else:
-            if fid in self.iterkeys():
-                self[fid].set_model(self.model)
+        elif fid in self:
+            self[fid].set_model(self.model)
 
     def get_model(self, fid):
@@ -272,5 +369,5 @@
         :return: saved model
         """
-        if fid in self.iterkeys():
+        if fid in self:
             return self[fid].get_model()
 
@@ -292,5 +389,5 @@
         :param data: data selected
         """
-        if fid in self.iterkeys():
+        if fid in self:
             self[fid].set_residuals(residuals)
 
@@ -299,5 +396,5 @@
         :return: residuals
         """
-        if fid in self.iterkeys():
+        if fid in self:
             return self[fid].get_residuals()
 
@@ -307,5 +404,5 @@
         :param data: data selected
         """
-        if fid in self.iterkeys():
+        if fid in self:
             self[fid].set_theory_data(data)
 
@@ -314,5 +411,5 @@
         :return: list of data dList
         """
-        if fid in self.iterkeys():
+        if fid in self:
             return self[fid].get_theory_data()
 
@@ -323,5 +420,5 @@
         :note: only data changes in the fit problem
         """
-        if data.id not in self.iterkeys():
+        if data.id not in self:
             self[data.id] = FitProblem()
         self[data.id].set_fit_data(data)
@@ -337,6 +434,6 @@
             data = []
         for d in data:
-            if (d is not None):
-                if (d.id not in self.iterkeys()):
+            if d is not None:
+                if d.id not in self:
                     self[d.id] = FitProblem()
                 self[d.id].set_fit_data(d)
@@ -349,5 +446,5 @@
         :param fid: key representing a fitproblem, usually extract from data id
         """
-        if fid in self.iterkeys():
+        if fid in self:
             return self[fid].get_fit_data()
 
@@ -359,9 +456,8 @@
         """
         if fid is None:
-            for value in self.itervalues():
+            for value in self.values():
                 value.set_model_param(name, value)
-        else:
-            if fid in self.iterkeys():
-                self[fid].set_model_param(name, value)
+        elif fid in self:
+            self[fid].set_model_param(name, value)
 
     def get_model_param(self, fid):
@@ -369,5 +465,5 @@
         return list of couple of parameter name and value
         """
-        if fid in self.iterkeys():
+        if fid in self:
             return self[fid].get_model_param()
 
@@ -390,5 +486,5 @@
         """
         self.scheduled = schedule
-        for value in self.itervalues():
+        for value in self.values():
             value.schedule_tofit(schedule)
 
@@ -406,9 +502,8 @@
         self.qmax = qmax
         if fid is None:
-            for value in self.itervalues():
+            for value in self.values():
                 value.set_range(self.qmin, self.qmax)
-        else:
-            if fid in self.iterkeys():
-                self[fid].value.set_range(self.qmin, self.qmax)
+        elif fid in self:
+            self[fid].value.set_range(self.qmin, self.qmax)
 
     def get_range(self, fid):
@@ -416,5 +511,5 @@
         :return: fitting range
         """
-        if fid in self.iterkeys():
+        if fid in self:
             return self[fid].get_range()
 
@@ -424,9 +519,8 @@
         """
         if fid is None:
-            for value in self.itervalues():
+            for value in self.values():
                 value.set_weight(flag=flag, is2d=is2d)
-        else:
-            if fid in self.iterkeys():
-                self[fid].set_weight(flag=flag, is2d=is2d)
+        elif fid in self:
+            self[fid].set_weight(flag=flag, is2d=is2d)
 
     def get_weight(self, fid=None):
@@ -434,5 +528,5 @@
         return fit weight
         """
-        if fid in self.iterkeys():
+        if fid in self:
             return self[fid].get_weight()
 
@@ -442,9 +536,8 @@
         """
         if fid is None:
-            for value in self.itervalues():
+            for value in self.values():
                 value.clear_model_param()
-        else:
-            if fid in self.iterkeys():
-                self[fid].clear_model_param()
+        elif fid in self:
+            self[fid].clear_model_param()
 
     def get_fit_problem(self):
@@ -452,10 +545,10 @@
         return fitproblem contained in this dictionary
         """
-        return self.itervalues()
+        return self.values()
 
     def set_result(self, result, fid):
         """
         """
-        if fid in self.iterkeys():
+        if fid in self:
             self[fid].set_result(result)
 
@@ -471,5 +564,5 @@
         get result
         """
-        if fid in self.iterkeys():
+        if fid in self:
             return self[fid].get_result()
 
@@ -491,262 +584,2 @@
         """
         return self.graph_id
-
-
-class FitProblem(FitProblemComponent):
-    """
-    FitProblem class allows to link a model with the new name created in _on_model,
-    a name theory created with that model  and the data fitted with the model.
-    FitProblem is mostly used  as value of the dictionary by fitting module.
-    """
-    def __init__(self):
-        FitProblemComponent.__init__(self)
-        """
-        contains information about data and model to fit
-        """
-        ## data used for fitting
-        self.fit_data = None
-        self.theory_data = None
-        self.residuals = None
-        # original data: should not be modified
-        self.original_data = None
-        ## the current model
-        self.model = None
-        ## if 1 this fit problem will be selected to fit , if 0
-        ## it will not be selected for fit
-        self.schedule = 0
-        ##list containing parameter name and value
-        self.list_param = []
-        ## smear object to smear or not data1D
-        self.smearer_computed = False
-        self.smearer_enable = False
-        self.smearer_computer_value = None
-        ## fitting range
-        self.qmin = None
-        self.qmax = None
-        # fit weight
-        self.weight = None
-        self.result = None
-
-    def enable_smearing(self, flag=False):
-        """
-        :param flag: bool.When flag is 1 get the computer smear value. When
-            flag is 0 ingore smear value.
-        """
-        self.smearer_enable = flag
-
-    def set_smearer(self, smearer):
-        """
-        save reference of  smear object on fitdata
-
-        :param smear: smear object from DataLoader
-
-        """
-        self.smearer_computer_value = smearer
-
-    def get_smearer(self):
-        """
-        return smear object
-        """
-        if not self.smearer_enable:
-            return None
-        if not self.smearer_computed:
-            #smeari_selection should be call only once per fitproblem
-            self.smearer_computer_value = smear_selection(self.fit_data,
-                                                           self.model)
-            self.smearer_computed = True
-        return self.smearer_computer_value
-
-    def save_model_name(self, name):
-        """
-        """
-        self.name_per_page = name
-
-    def get_name(self):
-        """
-        """
-        return self.name_per_page
-
-    def set_model(self, model):
-        """
-        associates each model with its new created name
-        :param model: model selected
-        :param name: name created for model
-        """
-        self.model = model
-        self.smearer_computer_value = smear_selection(self.fit_data,
-                                                           self.model)
-        self.smearer_computed = True
-
-    def get_model(self):
-        """
-        :return: saved model
-        """
-        return self.model
-
-    def set_residuals(self, residuals):
-        """
-        save a copy of residual
-        :param data: data selected
-        """
-        self.residuals = residuals
-
-    def get_residuals(self):
-        """
-        :return: residuals
-        """
-        return self.residuals
-
-    def set_theory_data(self, data):
-        """
-        save a copy of the data select to fit
-
-        :param data: data selected
-
-        """
-        self.theory_data = copy.deepcopy(data)
-
-    def get_theory_data(self):
-        """
-        :return: theory generated with the current model and data of this class
-        """
-        return self.theory_data
-
-    def set_fit_data(self, data):
-        """
-        Store data associated with this class
-        :param data: list of data selected
-        """
-        self.original_data = None
-        self.fit_data = None
-        # original data: should not be modified
-        self.original_data = data
-        # fit data: used for fit and can be modified for convenience
-        self.fit_data = copy.deepcopy(data)
-        self.smearer_computer_value = smear_selection(self.fit_data, self.model)
-        self.smearer_computed = True
-        self.result = None
-
-    def get_fit_data(self):
-        """
-        :return: data associate with this class
-        """
-        return self.fit_data
-
-    def get_origin_data(self):
-        """
-        """
-        return self.original_data
-
-    def set_weight(self, is2d, flag=None):
-        """
-        Received flag and compute error on data.
-        :param flag: flag to transform error of data.
-        :param is2d: flag to distinguish 1D to 2D Data
-        """
-        from sas.sasgui.perspectives.fitting.utils import get_weight
-        # send original data for weighting
-        self.weight = get_weight(data=self.original_data, is2d=is2d, flag=flag)
-        if is2d:
-            self.fit_data.err_data = self.weight
-        else:
-            self.fit_data.dy = self.weight
-
-    def get_weight(self):
-        """
-        returns weight array
-        """
-        return self.weight
-
-    def set_param2fit(self, list):
-        """
-        Store param names to fit (checked)
-        :param list: list of the param names
-        """
-        self.list_param2fit = list
-
-    def get_param2fit(self):
-        """
-        return the list param names to fit
-        """
-        return self.list_param2fit
-
-    def set_model_param(self, name, value=None):
-        """
-        Store the name and value of a parameter of this fitproblem's model
-        :param name: name of the given parameter
-        :param value: value of that parameter
-        """
-        self.list_param.append([name, value])
-
-    def get_model_param(self):
-        """
-        return list of couple of parameter name and value
-        """
-        return self.list_param
-
-    def schedule_tofit(self, schedule=0):
-        """
-        set schedule to true to decide if this fit  must be performed
-        """
-        self.schedule = schedule
-
-    def get_scheduled(self):
-        """
-        return true or false if a problem as being schedule for fitting
-        """
-        return self.schedule
-
-    def set_range(self, qmin=None, qmax=None):
-        """
-        set fitting range
-        :param qmin: minimum value to consider for the fit range
-        :param qmax: maximum value to consider for the fit range
-        """
-        self.qmin = qmin
-        self.qmax = qmax
-
-    def get_range(self):
-        """
-        :return: fitting range
-
-        """
-        return self.qmin, self.qmax
-
-    def clear_model_param(self):
-        """
-        clear constraint info
-        """
-        self.list_param = []
-
-    def set_fit_tab_caption(self, caption):
-        """
-        """
-        self.fit_tab_caption = str(caption)
-
-    def get_fit_tab_caption(self):
-        """
-        """
-        return self.fit_tab_caption
-
-    def set_graph_id(self, id):
-        """
-        Set graph id (from data_group_id at the time the graph produced)
-        """
-        self.graph_id = id
-
-    def get_graph_id(self):
-        """
-        Get graph_id
-        """
-        return self.graph_id
-
-    def set_result(self, result):
-        """
-        """
-        self.result = result
-
-    def get_result(self):
-        """
-        get result
-        """
-        return self.result
