Index: src/sas/sasgui/perspectives/fitting/basepage.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/basepage.py	(revision 313c5c92691602529afcffa8e76988a7cf6397b9)
+++ src/sas/sasgui/perspectives/fitting/basepage.py	(revision c8e19964f2dda929ccae8237e7b140a906cdf134)
@@ -19,5 +19,6 @@
 
 from sas.sasgui.guiframe.panel_base import PanelBase
-from sas.sasgui.guiframe.utils import format_number, check_float, IdList, check_int
+from sas.sasgui.guiframe.utils import format_number, check_float, IdList, \
+    check_int
 from sas.sasgui.guiframe.events import PanelOnFocusEvent
 from sas.sasgui.guiframe.events import StatusEvent
@@ -42,5 +43,5 @@
 _QMAX_DEFAULT = 0.5
 _NPTS_DEFAULT = 50
-#Control panel width
+# Control panel width
 if sys.platform.count("win32") > 0:
     PANEL_WIDTH = 450
@@ -57,7 +58,7 @@
     This class provide general structure of  fitpanel page
     """
-    ## Internal name for the AUI manager
+    # Internal name for the AUI manager
     window_name = "Fit Page"
-    ## Title to appear on top of the window
+    # Title to appear on top of the window
     window_caption = "Fit Page "
 
@@ -75,31 +76,31 @@
         PanelBase.__init__(self, parent)
         self.SetupScrolling()
-        #Set window's font size
+        # Set window's font size
         self.SetWindowVariant(variant=FONT_VARIANT)
         self.SetBackgroundColour(color)
 
         self._ids = iter(self._id_pool)
-        ## parent of the page
+        # parent of the page
         self.parent = parent
-        ## manager is the fitting plugin
-        ## owner of the page (fitting plugin)
+        # manager is the fitting plugin
+        # owner of the page (fitting plugin)
         self.event_owner = None
-        ## current model
+        # current model
         self.model = None
         self.m_name = None
         self.index_model = None
         self.panel = None
-        ## data
+        # data
         self.data = None
-        #list of available data
+        # list of available data
         self.data_list = []
         self.mask = None
         self.uid = wx.NewId()
         self.graph_id = None
-        #Q range for data set
+        # Q range for data set
         self.qmin_data_set = numpy.inf
         self.qmax_data_set = None
         self.npts_data_set = 0
-        ## Q range
+        # Q range
         self.qmin = None
         self.qmax = None
@@ -107,28 +108,28 @@
         self.qmin_x = _QMIN_DEFAULT
         self.npts_x = _NPTS_DEFAULT
-        ## total number of point: float
+        # total number of point: float
         self.npts = None
         self.num_points = None
-        ## smear default
+        # smear default
         self.current_smearer = None
-        ## 2D smear accuracy default
+        # 2D smear accuracy default
         self.smear2d_accuracy = 'Low'
-        ## slit smear:
+        # slit smear:
         self.dxl = None
         self.dxw = None
-        ## pinhole smear
+        # pinhole smear
         self.dx_min = None
         self.dx_max = None
-        ##semar attrbs
+        # smear attrbs
         self.enable_smearer = None
         self.disable_smearer = None
         self.pinhole_smearer = None
         self.slit_smearer = None
-        ##weigth attrbs
+        # weight attrbs
         self.dI_noweight = None
         self.dI_didata = None
         self.dI_sqrdata = None
         self.dI_idata = None
-        ##other attrbs
+        # other attrbs
         self.dq_l = None
         self.dq_r = None
@@ -149,13 +150,13 @@
         self.disp_cb_dict = {}
 
-        #self.state = PageState(parent=parent)
-        ## dictionary containing list of models
+        # self.state = PageState(parent=parent)
+        # dictionary containing list of models
         self.model_list_box = {}
 
-        ## Data member to store the dispersion object created
+        # Data member to store the dispersion object created
         self._disp_obj_dict = {}
-        ## selected parameters to apply dispersion
+        # selected parameters to apply dispersion
         self.disp_cb_dict = {}
-        ## smearer object
+        # smearer object
         self.enable2D = False
         self._has_magnetic = False
@@ -165,21 +166,21 @@
         self.structurebox = None
         self.categorybox = None
-        ##list of model parameters. each item must have same length
-        ## each item related to a given parameters
-        ##[cb state, name, value, "+/-", error of fit, min, max , units]
+        # list of model parameters. each item must have same length
+        # each item related to a given parameters
+        # [cb state, name, value, "+/-", error of fit, min, max , units]
         self.parameters = []
         # non-fittable parameter whose value is astring
         self.str_parameters = []
-        ## list of parameters to fit , must be like self.parameters
+        # list of parameters to fit , must be like self.parameters
         self.param_toFit = []
-        ## list of looking like parameters but with non fittable parameters info
+        # list of looking like parameters but with non fittable parameters info
         self.fixed_param = []
-        ## list of looking like parameters but with  fittable parameters info
+        # list of looking like parameters but with  fittable parameters info
         self.fittable_param = []
-        ##list of dispersion parameters
+        # list of dispersion parameters
         self.disp_list = []
         self.disp_name = ""
 
-        ## list of orientation parameters
+        # list of orientation parameters
         self.orientation_params = []
         self.orientation_params_disp = []
@@ -188,24 +189,24 @@
 #       and this - commenting out on 4/8/2014 by PDB.  Remove once clear
 #       it is pointless.
-#        if self.model != None:
+#        if self.model is not None:
 #            self.disp_list = self.model.getDispParamList()
         self.temp_multi_functional = False
-        ##enable model 2D draw
+        # enable model 2D draw
         self.enable2D = False
-        ## check that the fit range is correct to plot the model again
+        # check that the fit range is correct to plot the model again
         self.fitrange = True
-        ## Create memento to save the current state
+        # Create memento to save the current state
         self.state = PageState(parent=self.parent,
                                model=self.model, data=self.data)
-        ## flag to determine if state has change
+        # flag to determine if state has change
         self.state_change = False
-        ## save customized array
+        # save customized array
         self.values = {}   # type: Dict[str, List[float, ...]]
         self.weights = {}   # type: Dict[str, List[float, ...]]
-        ## retrieve saved state
+        # retrieve saved state
         self.number_saved_state = 0
-        ## dictionary of saved state
+        # dictionary of saved state
         self.saved_states = {}
-        ## Create context menu for page
+        # Create context menu for page
         self.popUpMenu = wx.Menu()
 
@@ -220,8 +221,8 @@
         self.popUpMenu.AppendSeparator()
 
-        ## Default locations
+        # Default locations
         self._default_save_location = os.getcwd()
-        ## save initial state on context menu
-        #self.onSave(event=None)
+        # save initial state on context menu
+        # self.onSave(event=None)
         self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu)
 
@@ -229,10 +230,10 @@
         self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down)
 
-        ## create the basic structure of the panel with empty sizer
+        # create the basic structure of the panel with empty sizer
         self.define_page_structure()
-        ## drawing Initial dispersion parameters sizer
+        # drawing Initial dispersion parameters sizer
         self.set_dispers_sizer()
 
-        ## layout
+        # layout
         self.set_layout()
 
@@ -260,8 +261,8 @@
                     self._create_default_1d_data()
 
-            if self.model != None:
+            if self.model is not None:
                 if not self.data.is_data:
-                    self._manager.page_finder[self.uid].set_fit_data(data=\
-                                                                [self.data])
+                    self._manager.page_finder[self.uid].set_fit_data(
+                        data=[self.data])
             self.on_smear_helper(update=True)
             self.state.enable_smearer = self.enable_smearer.GetValue()
@@ -325,5 +326,5 @@
         self.data.id = str(self.uid) + " data"
         self.data.group_id = str(self.uid) + " Model2D"
-        ## Default values
+        # Default values
         self.data.detector.append(Detector())
         index = len(self.data.detector) - 1
@@ -342,5 +343,5 @@
         x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True)
         y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True)
-        ## use data info instead
+        # use data info instead
         new_x = numpy.tile(x, (len(y), 1))
         new_y = numpy.tile(y, (len(x), 1))
@@ -383,11 +384,11 @@
         Update menu1 on cliking the page tap
         """
-        if self._manager.menu1 != None:
-            chain_menu = self._manager.menu1.FindItemById(\
+        if self._manager.menu1 is not None:
+            chain_menu = self._manager.menu1.FindItemById(
                                                    self._manager.id_reset_flag)
             chain_menu.Enable(self.batch_on)
             sim_menu = self._manager.menu1.FindItemById(self._manager.id_simfit)
             flag = self.data.is_data\
-                            and (self.model != None)
+                            and (self.model is not None)
             sim_menu.Enable(not self.batch_on and flag)
             batch_menu = \
@@ -530,5 +531,5 @@
         fill sizer containing dispersity info
         """
-        #print "==== entering set_dispers_sizer ==="
+        # print "==== entering set_dispers_sizer ==="
         self.sizer4.Clear(True)
         name = "Polydispersity and Orientational Distribution"
@@ -536,5 +537,5 @@
         box_description.SetForegroundColour(wx.BLUE)
         boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
-        #----------------------------------------------------
+        # ----------------------------------------------------
         self.disable_disp = wx.RadioButton(self, wx.ID_ANY, 'Off', (10, 10),
                                            style=wx.RB_GROUP)
@@ -556,5 +557,5 @@
         self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param,
                   id=self.enable_disp.GetId())
-        #MAC needs SetValue
+        # MAC needs SetValue
         self.disable_disp.SetValue(True)
         sizer_dispersion = wx.BoxSizer(wx.HORIZONTAL)
@@ -568,5 +569,5 @@
         sizer_dispersion.Add(self.disp_help_bt)
 
-        ## fill a sizer for dispersion
+        # fill a sizer for dispersion
         boxsizer1.Add(sizer_dispersion, 0,
                       wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE,
@@ -575,5 +576,5 @@
 
         boxsizer1.Add(self.sizer4_4)
-        #-----------------------------------------------------
+        # -----------------------------------------------------
         self.sizer4.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10)
         self.sizer4_4.Layout()
@@ -582,5 +583,5 @@
 
         self.Refresh()
-        ## saving the state of enable dispersity button
+        # saving the state of enable dispersity button
         self.state.enable_disp = self.enable_disp.GetValue()
         self.state.disable_disp = self.disable_disp.GetValue()
@@ -592,5 +593,5 @@
         """
         menu = event.GetEventObject()
-        ## post help message for the selected model
+        # post help message for the selected model
         msg = menu.GetHelpString(event.GetId())
         msg += " reloaded"
@@ -599,9 +600,9 @@
         name = menu.GetLabel(event.GetId())
         self._on_select_model_helper()
-        if self.model != None:
+        if self.model is not None:
             self.m_name = self.model.name
         if name in self.saved_states.keys():
             previous_state = self.saved_states[name]
-            ## reset state of checkbox,textcrtl  and  regular parameters value
+            # reset state of checkbox,textcrtl  and  regular parameters value
 
             self.reset_page(previous_state)
@@ -626,5 +627,5 @@
         # Ask the user the location of the file to write to.
         path = None
-        if self.parent != None:
+        if self.parent is not None:
             self._default_save_location = \
                         self._manager.parent._default_save_location
@@ -636,5 +637,5 @@
             self._default_save_location = os.path.dirname(path)
             self._manager.parent._default_save_location = \
-                                self._default_save_location
+                self._default_save_location
         else:
             return None
@@ -643,5 +644,5 @@
         # Make sure the ext included in the file name
         fName = os.path.splitext(path)[0] + extens
-        #the manager write the state into file
+        # the manager write the state into file
         self._manager.save_fit_state(filepath=fName, fitstate=new_state)
         return new_state
@@ -651,5 +652,5 @@
         Copy Parameter values to the clipboad
         """
-        if event != None:
+        if event is not None:
             event.Skip()
         # It seems MAC needs wxCallAfter
@@ -667,5 +668,5 @@
         Paste Parameter values to the panel if possible
         """
-        #if event != None:
+        # if event is not None:
         #    event.Skip()
         # It seems MAC needs wxCallAfter for the setvalues
@@ -673,5 +674,5 @@
         wx.CallAfter(self.get_paste)
         # messages depending on the flag
-        #self._copy_info(True)
+        # self._copy_info(True)
 
     def _copy_info(self, flag):
@@ -682,5 +683,5 @@
         """
         # messages depending on the flag
-        if flag == None:
+        if flag is None:
             msg = " Parameter values are copied to the clipboard..."
             infor = 'warning'
@@ -710,5 +711,5 @@
         save history of the data and model
         """
-        if self.model == None:
+        if self.model is None:
             msg = "Can not bookmark; Please select Data and Model first..."
             wx.MessageBox(msg, 'Info')
@@ -716,8 +717,8 @@
         self.save_current_state()
         new_state = self.state.clone()
-        ##Add model state on context menu
+        # Add model state on context menu
         self.number_saved_state += 1
         current_time, current_date = self._get_time_stamp()
-        #name= self.model.name+"[%g]"%self.number_saved_state
+        # name= self.model.name+"[%g]"%self.number_saved_state
         name = "Fitting: %g]" % self.number_saved_state
         name += self.model.__class__.__name__
@@ -725,7 +726,7 @@
         self.saved_states[name] = new_state
 
-        ## Add item in the context menu
+        # Add item in the context menu
         msg = "Model saved at %s on %s" % (current_time, current_date)
-        ## post help message for the selected model
+        # post help message for the selected model
         msg += " Saved! right click on this page to retrieve this model"
         wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
@@ -761,5 +762,5 @@
         """
         try:
-            if path == None:
+            if path is None:
                 status = " Selected Distribution was not loaded: %s" % path
                 wx.PostEvent(self._manager.parent,
@@ -796,33 +797,33 @@
         Store current state
         """
-        ## save model option
-        if self.model != None:
+        # save model option
+        if self.model is not None:
             self.disp_list = self.model.getDispParamList()
             self.state.disp_list = copy.deepcopy(self.disp_list)
             self.state.model = self.model.clone()
 
-            #model combobox: complex code because of mac's silent error
-            if self.structurebox != None:
+            # model combobox: complex code because of mac's silent error
+            if self.structurebox is not None:
                 if self.structurebox.IsShown():
                     self.state.structurecombobox = 'None'
                     s_select = self.structurebox.GetSelection()
                     if s_select > 0:
-                        self.state.structurecombobox = self.structurebox.\
-                        GetString(s_select)
-            if self.formfactorbox != None:
+                        self.state.structurecombobox = \
+                            self.structurebox.GetString(s_select)
+            if self.formfactorbox is not None:
                 f_select = self.formfactorbox.GetSelection()
                 if f_select > 0:
-                    self.state.formfactorcombobox = self.formfactorbox.\
-                    GetString(f_select)
-        if self.categorybox != None:
+                    self.state.formfactorcombobox = \
+                        self.formfactorbox.GetString(f_select)
+        if self.categorybox is not None:
             cb_select = self.categorybox.GetSelection()
             if cb_select > 0:
-                self.state.categorycombobox = self.categorybox.\
-                GetString(cb_select)
+                self.state.categorycombobox = \
+                    self.categorybox.GetString(cb_select)
 
         self.state.enable2D = copy.deepcopy(self.enable2D)
         self.state.values = copy.deepcopy(self.values)
         self.state.weights = copy.deepcopy(self.weights)
-        ## save data
+        # save data
         self.state.data = copy.deepcopy(self.data)
         self.state.qmax_x = self.qmax_x
@@ -859,5 +860,5 @@
             self.state.values = copy.deepcopy(self.values)
             self.state.weights = copy.deepcopy(self.weights)
-        ## save plotting range
+        # save plotting range
         self._save_plotting_range()
 
@@ -869,5 +870,5 @@
         self.state.str_parameters = []
 
-        ## save checkbutton state and txtcrtl values
+        # save checkbutton state and txtcrtl values
         self._copy_parameters_state(self.str_parameters,
                                     self.state.str_parameters)
@@ -881,5 +882,5 @@
                                     self.state.fittable_param)
         self._copy_parameters_state(self.fixed_param, self.state.fixed_param)
-        #save chisqr
+        # save chisqr
         self.state.tcChi = self.tcChi.GetValue()
 
@@ -888,6 +889,6 @@
         Store current state for fit_page
         """
-        ## save model option
-        if self.model != None:
+        # save model option
+        if self.model is not None:
             self.disp_list = self.model.getDispParamList()
             self.state.disp_list = copy.deepcopy(self.disp_list)
@@ -897,5 +898,5 @@
         self.state.values = copy.deepcopy(self.values)
         self.state.weights = copy.deepcopy(self.weights)
-        ## save data
+        # save data
         self.state.data = copy.deepcopy(self.data)
 
@@ -918,10 +919,10 @@
         self.state.dI_sqrdata = copy.deepcopy(self.dI_sqrdata.GetValue())
         self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue())
-        if hasattr(self, "disp_box") and self.disp_box != None:
+        if hasattr(self, "disp_box") and self.disp_box is not None:
             self.state.disp_box = self.disp_box.GetCurrentSelection()
 
             if len(self.disp_cb_dict) > 0:
                 for k, v in self.disp_cb_dict.iteritems():
-                    if v == None:
+                    if v is None:
                         self.state.disp_cb_dict[k] = v
                     else:
@@ -937,8 +938,8 @@
             self.state.weights = copy.deepcopy(self.weights)
 
-        ## save plotting range
+        # save plotting range
         self._save_plotting_range()
 
-        ## save checkbutton state and txtcrtl values
+        # save checkbutton state and txtcrtl values
         self._copy_parameters_state(self.orientation_params,
                                     self.state.orientation_params)
@@ -959,5 +960,5 @@
             msg = "Please load Data and select Model to start..."
             wx.MessageBox(msg, 'Info')
-            return  True
+            return True
 
     def set_model_state(self, state):
@@ -968,7 +969,7 @@
         self.disp_list = state.disp_list
 
-        ## fill model combobox
+        # fill model combobox
         self._show_combox_helper()
-        #select the current model
+        # select the current model
         try:
             # to support older version
@@ -1009,8 +1010,8 @@
         self.structurebox.SetSelection(structfactor_pos)
 
-        if state.multi_factor != None:
+        if state.multi_factor is not None:
             self.multifactorbox.SetSelection(state.multi_factor)
 
-        ## reset state of checkbox,textcrtl  and  regular parameters value
+        # reset state of checkbox,textcrtl  and  regular parameters value
         self._reset_parameters_state(self.orientation_params_disp,
                                      state.orientation_params_disp)
@@ -1020,9 +1021,9 @@
                                      state.str_parameters)
         self._reset_parameters_state(self.parameters, state.parameters)
-        ## display dispersion info layer
+        # display dispersion info layer
         self.enable_disp.SetValue(state.enable_disp)
         self.disable_disp.SetValue(state.disable_disp)
 
-        if hasattr(self, "disp_box") and self.disp_box != None:
+        if hasattr(self, "disp_box") and self.disp_box is not None:
             self.disp_box.SetSelection(state.disp_box)
             n = self.disp_box.GetCurrentSelection()
@@ -1036,10 +1037,10 @@
 
                     if hasattr(self.disp_cb_dict[item], "SetValue"):
-                        self.disp_cb_dict[item].SetValue(\
+                        self.disp_cb_dict[item].SetValue(
                                                     state.disp_cb_dict[item])
                         # Create the dispersion objects
                         disp_model = POLYDISPERSITY_MODELS['array']()
                         if hasattr(state, "values") and \
-                                 self.disp_cb_dict[item].GetValue() == True:
+                                 self.disp_cb_dict[item].GetValue() is True:
                             if len(state.values) > 0:
                                 self.values = state.values
@@ -1052,5 +1053,5 @@
                         self._disp_obj_dict[item] = disp_model
                         # Set the new model as the dispersion object
-                        #for the selected parameter
+                        # for the selected parameter
                         self.model.set_dispersion(item, disp_model)
 
@@ -1062,12 +1063,12 @@
                 for item in keys:
                     if item in self.disp_list and \
-                        not item in self.model.details:
+                            item not in self.model.details:
                         self.model.details[item] = ["", None, None]
                 self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict)
                 self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict)
-        ## smearing info  restore
+        # smearing info  restore
         if hasattr(self, "enable_smearer"):
-            ## set smearing value whether or not the data
-            #contain the smearing info
+            # set smearing value whether or not the data
+            # contain the smearing info
             self.enable_smearer.SetValue(state.enable_smearer)
             self.disable_smearer.SetValue(state.disable_smearer)
@@ -1081,5 +1082,5 @@
         self.dI_idata.SetValue(state.dI_idata)
 
-        ## we have two more options for smearing
+        # we have two more options for smearing
         if self.pinhole_smearer.GetValue():
             self.onPinholeSmear(event=None)
@@ -1087,12 +1088,12 @@
             self.onSlitSmear(event=None)
 
-        ## reset state of checkbox,textcrtl  and dispersity parameters value
+        # reset state of checkbox,textcrtl  and dispersity parameters value
         self._reset_parameters_state(self.fittable_param, state.fittable_param)
         self._reset_parameters_state(self.fixed_param, state.fixed_param)
 
-        ## draw the model with previous parameters value
+        # draw the model with previous parameters value
         self._onparamEnter_helper()
         self.select_param(event=None)
-        #Save state_fit
+        # Save state_fit
         self.save_current_state_fit()
         self._lay_out()
@@ -1108,4 +1109,5 @@
                 if state.formfactorcombobox in list_item:
                     return self.categorybox.Items.index(key)
+        return 0
 
     def reset_page_helper(self, state):
@@ -1118,5 +1120,5 @@
             state of the graphic interface
         """
-        if state == None:
+        if state is None:
             return
         # set data, etc. from the state
@@ -1124,5 +1126,5 @@
         data = state.data
 
-        if data == None:
+        if data is None:
             data_min = state.qmin
             data_max = state.qmax
@@ -1148,14 +1150,16 @@
         self.disp_list = state.disp_list
 
-        ## fill model combobox
+        # fill model combobox
         self._show_combox_helper()
-        #select the current model
+        # select the current model
         try:
             # to support older version
             category_pos = int(state.categorycombobox)
         except:
-            state.formfactorcombobox = unicode(state.formfactorcombobox.lower())
+            state.formfactorcombobox = state.formfactorcombobox.lower()
+            state.formfactorcombobox = \
+                state.formfactorcombobox.replace('model', '')
+            state.formfactorcombobox = unicode(state.formfactorcombobox)
             state.categorycombobox = unicode(state.categorycombobox)
-            category_pos = 0
             if state.categorycombobox in self.categorybox.Items:
                 category_pos = self.categorybox.Items.index(
@@ -1180,4 +1184,5 @@
         self.formfactorbox.Select(formfactor_pos)
 
+        structfactor_pos = 0
         try:
             # to support older version
@@ -1185,9 +1190,8 @@
         except:
             if state.structurecombobox is not None:
-                structfactor_pos = 0
                 state.structurecombobox = unicode(state.structurecombobox)
                 for ind_struct in range(self.structurebox.GetCount()):
                     if self.structurebox.GetString(ind_struct) == \
-                                                        (state.structurecombobox):
+                                                    (state.structurecombobox):
                         structfactor_pos = int(ind_struct)
                         break
@@ -1195,12 +1199,12 @@
         self.structurebox.SetSelection(structfactor_pos)
 
-        if state.multi_factor != None:
+        if state.multi_factor is not None:
             self.multifactorbox.SetSelection(state.multi_factor)
 
-        #draw the panel according to the new model parameter
+        # draw the panel according to the new model parameter
         self._on_select_model(event=None)
 
         # take care of 2D button
-        if data == None and self.model_view.IsEnabled():
+        if data is None and self.model_view.IsEnabled():
             if self.enable2D:
                 self.model_view.SetLabel("2D Mode")
@@ -1208,5 +1212,5 @@
                 self.model_view.SetLabel("1D Mode")
 
-        ## reset state of checkbox,textcrtl  and  regular parameters value
+        # reset state of checkbox,textcrtl  and  regular parameters value
         self._reset_parameters_state(self.orientation_params_disp,
                                      state.orientation_params_disp)
@@ -1216,5 +1220,5 @@
                                      state.str_parameters)
         self._reset_parameters_state(self.parameters, state.parameters)
-        ## display dispersion info layer
+        # display dispersion info layer
         self.enable_disp.SetValue(state.enable_disp)
         self.disable_disp.SetValue(state.disable_disp)
@@ -1224,10 +1228,10 @@
             self._set_dipers_Param(event=None)
             self._reset_page_disp_helper(state)
-        ##plotting range restore
+        # plotting range restore
         self._reset_plotting_range(state)
-        ## smearing info  restore
+        # smearing info  restore
         if hasattr(self, "enable_smearer"):
-            ## set smearing value whether or not the data
-            #contain the smearing info
+            # set smearing value whether or not the data
+            # contain the smearing info
             self.enable_smearer.SetValue(state.enable_smearer)
             self.disable_smearer.SetValue(state.disable_smearer)
@@ -1247,11 +1251,11 @@
             self.dI_idata.SetValue(False)
 
-        ## we have two more options for smearing
+        # we have two more options for smearing
         if self.pinhole_smearer.GetValue():
             self.dx_min = state.dx_min
             self.dx_max = state.dx_max
-            if self.dx_min != None:
+            if self.dx_min is not None:
                 self.smear_pinhole_min.SetValue(str(self.dx_min))
-            if self.dx_max != None:
+            if self.dx_max is not None:
                 self.smear_pinhole_max.SetValue(str(self.dx_max))
             self.onPinholeSmear(event=None)
@@ -1259,7 +1263,7 @@
             self.dxl = state.dxl
             self.dxw = state.dxw
-            if self.dxl != None:
+            if self.dxl is not None:
                 self.smear_slit_height.SetValue(str(self.dxl))
-            if self.dxw != None:
+            if self.dxw is not None:
                 self.smear_slit_width.SetValue(str(self.dxw))
             else:
@@ -1267,16 +1271,16 @@
             self.onSlitSmear(event=None)
 
-        ## reset state of checkbox,textcrtl  and dispersity parameters value
+        # reset state of checkbox,textcrtl  and dispersity parameters value
         self._reset_parameters_state(self.fittable_param, state.fittable_param)
         self._reset_parameters_state(self.fixed_param, state.fixed_param)
 
-        ## draw the model with previous parameters value
+        # draw the model with previous parameters value
         self._onparamEnter_helper()
-        #reset the value of chisqr when not consistent with the value computed
+        # reset the value of chisqr when not consistent with the value computed
         self.tcChi.SetValue(str(self.state.tcChi))
-        ## reset context menu items
+        # reset context menu items
         self._reset_context_menu()
 
-        ## set the value of the current state to the state given as parameter
+        # set the value of the current state to the state given as parameter
         self.state = state.clone()
         self.state.m_name = self.m_name
@@ -1289,7 +1293,7 @@
         for item in keys:
             if item in self.disp_list and \
-                not item in self.model.details:
+                            item not in self.model.details:
                 self.model.details[item] = ["", None, None]
-        #for k,v in self.state.disp_cb_dict.iteritems():
+        # for k,v in self.state.disp_cb_dict.iteritems():
         self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict)
         self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict)
@@ -1298,5 +1302,5 @@
 
         for key, disp_type in state._disp_obj_dict.iteritems():
-            #disp_model = disp
+            # disp_model = disp
             disp_model = POLYDISPERSITY_MODELS[disp_type]()
             self._disp_obj_dict[key] = disp_model
@@ -1307,10 +1311,10 @@
                 self.model.set_dispersion(param_name, disp_model)
                 self.model._persistency_dict[key] = \
-                                 [state.values, state.weights]
+                    [state.values, state.weights]
             except Exception:
                 logging.error(traceback.format_exc())
             selection = self._find_polyfunc_selection(disp_model)
             for list in self.fittable_param:
-                if list[1] == key and list[7] != None:
+                if list[1] == key and list[7] is not None:
                     list[7].SetSelection(selection)
                     # For the array disp_model, set the values and weights
@@ -1341,5 +1345,5 @@
         open a dialog file to selected the customized dispersity
         """
-        if self.parent != None:
+        if self.parent is not None:
             self._default_save_location = \
                         self._manager.parent.get_save_location()
@@ -1360,5 +1364,5 @@
         for name, _ in self.state.saved_states.iteritems():
             self.number_saved_state += 1
-            ## Add item in the context menu
+            # Add item in the context menu
             wx_id = ids.next()
             msg = 'Save model and state %g' % self.number_saved_state
@@ -1377,13 +1381,13 @@
         save radiobutton containing the type model that can be selected
         """
-        #self.state.shape_rbutton = self.shape_rbutton.GetValue()
-        #self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue()
-        #self.state.struct_rbutton = self.struct_rbutton.GetValue()
-        #self.state.plugin_rbutton = self.plugin_rbutton.GetValue()
+        # self.state.shape_rbutton = self.shape_rbutton.GetValue()
+        # self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue()
+        # self.state.struct_rbutton = self.struct_rbutton.GetValue()
+        # self.state.plugin_rbutton = self.plugin_rbutton.GetValue()
         self.state.structurecombobox = self.structurebox.GetLabel()
         self.state.formfactorcombobox = self.formfactorbox.GetLabel()
         self.state.categorycombobox = self.categorybox.GetLabel()
 
-        ## post state to fit panel
+        # post state to fit panel
         event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
@@ -1397,5 +1401,5 @@
         self.state.npts = self.npts_x
 
-    def _onparamEnter_helper(self,is_modified = False):
+    def _onparamEnter_helper(self, is_modified=False):
         """
         check if values entered by the user are changed and valid to replot
@@ -1403,14 +1407,14 @@
         """
         # Flag to register when a parameter has changed.
-        #is_modified = False
+        # is_modified = False
         self.fitrange = True
         is_2Ddata = False
-        #self._undo.Enable(True)
+        # self._undo.Enable(True)
         # check if 2d data
         if self.data.__class__.__name__ == "Data2D":
             is_2Ddata = True
-        if self.model != None:
-            #Either we get a is_modified = True passed in because
-            #_update_paramv_on_fit() has been called already or
+        if self.model is not None:
+            # Either we get a is_modified = True passed in because
+            # _update_paramv_on_fit() has been called already or
             # we need to check here ourselves.
             if not is_modified:
@@ -1439,7 +1443,7 @@
                 self.fitrange = False
 
-            ## if any value is modify draw model with new value
+            # if any value is modify draw model with new value
             if not self.fitrange:
-                #self.btFit.Disable()
+                # self.btFit.Disable()
                 if is_2Ddata:
                     self.btEditMask.Disable()
@@ -1455,5 +1459,5 @@
                 self.Refresh()
 
-        #logging.info("is_modified flag set to %g",is_modified)
+        # logging.info("is_modified flag set to %g",is_modified)
         return is_modified
 
@@ -1462,23 +1466,23 @@
         make sure that update param values just before the fitting
         """
-        #flag for qmin qmax check values
+        # flag for qmin qmax check values
         flag = True
         self.fitrange = True
         is_modified = False
 
-        #wx.PostEvent(self._manager.parent, StatusEvent(status=" \
-        #updating ... ",type="update"))
-
-        ##So make sure that update param values on_Fit.
-        #self._undo.Enable(True)
-        if self.model != None:
+        # wx.PostEvent(self._manager.parent, StatusEvent(status=" \
+        # updating ... ",type="update"))
+
+        # So make sure that update param values on_Fit.
+        # self._undo.Enable(True)
+        if self.model is not None:
             if self.Npts_total.GetValue() != self.Npts_fit.GetValue():
                 if not self.data.is_data:
-                    self._manager.page_finder[self.uid].set_fit_data(data=\
-                                                                [self.data])
-            ##Check the values
+                    self._manager.page_finder[self.uid].set_fit_data(
+                        data=[self.data])
+            # Check the values
             is_modified = (self._check_value_enter(self.fittable_param)
-                            or self._check_value_enter(self.fixed_param)
-                            or self._check_value_enter(self.parameters))
+                           or self._check_value_enter(self.fixed_param)
+                           or self._check_value_enter(self.parameters))
 
             # If qmin and qmax have been modified, update qmin and qmax and
@@ -1521,8 +1525,8 @@
                                               enable_smearer=enable_smearer,
                                               draw=False)
-                    if self.data != None:
-                        index_data = ((self.qmin_x <= self.data.x) & \
+                    if self.data is not None:
+                        index_data = ((self.qmin_x <= self.data.x) &
                                       (self.data.x <= self.qmax_x))
-                        val = str(len(self.data.x[index_data == True]))
+                        val = str(len(self.data.x[index_data is True]))
                         self.Npts_fit.SetValue(val)
                     else:
@@ -1544,10 +1548,10 @@
             flag = False
 
-        #For invalid q range, disable the mask editor and fit button, vs.
+        # For invalid q range, disable the mask editor and fit button, vs.
         if not self.fitrange:
             if self._is_2D():
                 self.btEditMask.Disable()
         else:
-            if self._is_2D() and  self.data.is_data and not self.batch_on:
+            if self._is_2D() and self.data.is_data and not self.batch_on:
                 self.btEditMask.Enable(True)
 
@@ -1562,5 +1566,5 @@
             logging.error(traceback.format_exc())
 
-        return flag,is_modified
+        return flag, is_modified
 
     def _reset_parameters_state(self, listtorestore, statelist):
@@ -1576,8 +1580,8 @@
             item_page = listtorestore[j]
             item_page_info = statelist[j]
-            ##change the state of the check box for simple parameters
-            if item_page[0] != None:
+            # change the state of the check box for simple parameters
+            if item_page[0] is not None:
                 item_page[0].SetValue(item_page_info[0])
-            if item_page[2] != None:
+            if item_page[2] is not None:
                 item_page[2].SetValue(item_page_info[2])
                 if item_page[2].__class__.__name__ == "ComboBox":
@@ -1585,12 +1589,12 @@
                         fun_val = self.model.fun_list[item_page_info[2]]
                         self.model.setParam(item_page_info[1], fun_val)
-            if item_page[3] != None:
-                ## show or hide text +/-
+            if item_page[3] is not None:
+                # show or hide text +/-
                 if item_page_info[2]:
                     item_page[3].Show(True)
                 else:
                     item_page[3].Hide()
-            if item_page[4] != None:
-                ## show of hide the text crtl for fitting error
+            if item_page[4] is not None:
+                # show of hide the text crtl for fitting error
                 if item_page_info[4][0]:
                     item_page[4].Show(True)
@@ -1598,11 +1602,11 @@
                 else:
                     item_page[3].Hide()
-            if item_page[5] != None:
-                ## show of hide the text crtl for fitting error
+            if item_page[5] is not None:
+                # show of hide the text crtl for fitting error
                 item_page[5].Show(item_page_info[5][0])
                 item_page[5].SetValue(item_page_info[5][1])
 
-            if item_page[6] != None:
-                ## show of hide the text crtl for fitting error
+            if item_page[6] is not None:
+                # show of hide the text crtl for fitting error
                 item_page[6].Show(item_page_info[6][0])
                 item_page[6].SetValue(item_page_info[6][1])
@@ -1620,10 +1624,10 @@
             item_page = listtorestore[j]
             item_page_info = statelist[j]
-            ##change the state of the check box for simple parameters
-
-            if item_page[0] != None:
+            # change the state of the check box for simple parameters
+
+            if item_page[0] is not None:
                 item_page[0].SetValue(format_number(item_page_info[0], True))
 
-            if item_page[2] != None:
+            if item_page[2] is not None:
                 param_name = item_page_info[1]
                 value = item_page_info[2]
@@ -1648,16 +1652,16 @@
 
             checkbox_state = None
-            if item[0] != None:
+            if item[0] is not None:
                 checkbox_state = item[0].GetValue()
             parameter_name = item[1]
             parameter_value = None
-            if item[2] != None:
+            if item[2] is not None:
                 parameter_value = item[2].GetValue()
             static_text = None
-            if item[3] != None:
+            if item[3] is not None:
                 static_text = item[3].IsShown()
             error_value = None
             error_state = None
-            if item[4] != None:
+            if item[4] is not None:
                 error_value = item[4].GetValue()
                 error_state = item[4].IsShown()
@@ -1665,5 +1669,5 @@
             min_value = None
             min_state = None
-            if item[5] != None:
+            if item[5] is not None:
                 min_value = item[5].GetValue()
                 min_state = item[5].IsShown()
@@ -1671,9 +1675,9 @@
             max_value = None
             max_state = None
-            if item[6] != None:
+            if item[6] is not None:
                 max_value = item[6].GetValue()
                 max_state = item[6].IsShown()
             unit = None
-            if item[7] != None:
+            if item[7] is not None:
                 unit = item[7].GetLabel()
 
@@ -1683,5 +1687,4 @@
                               [max_state, max_value], unit])
 
-
     def _draw_model(self, update_chisqr=True, source='model'):
         """
@@ -1702,7 +1705,7 @@
         :param chisqr: update chisqr value [bool]
         """
-        #if self.check_invalid_panel():
+        # if self.check_invalid_panel():
         #    return
-        if self.model != None:
+        if self.model is not None:
             temp_smear = None
             if hasattr(self, "enable_smearer"):
@@ -1716,15 +1719,15 @@
             is_2d = self._is_2D()
             self._manager.draw_model(self.model,
-                                    data=self.data,
-                                    smearer=temp_smear,
-                                    qmin=float(self.qmin_x),
-                                    qmax=float(self.qmax_x),
-                                    page_id=self.uid,
-                                    toggle_mode_on=toggle_mode_on,
-                                    state=self.state,
-                                    enable2D=is_2d,
-                                    update_chisqr=update_chisqr,
-                                    source='model',
-                                    weight=weight)
+                                     data=self.data,
+                                     smearer=temp_smear,
+                                     qmin=float(self.qmin_x),
+                                     qmax=float(self.qmax_x),
+                                     page_id=self.uid,
+                                     toggle_mode_on=toggle_mode_on,
+                                     state=self.state,
+                                     enable2D=is_2d,
+                                     update_chisqr=update_chisqr,
+                                     source='model',
+                                     weight=weight)
 
     def _on_show_sld(self, event=None):
@@ -1736,7 +1739,7 @@
 
         from sas.sasgui.plottools import Data1D as pf_data1d
-        #from sas.sasgui.perspectives.theory.profile_dialog import SLDPanel
+        # from sas.sasgui.perspectives.theory.profile_dialog import SLDPanel
         from sas.sasgui.guiframe.local_perspectives.plotting.profile_dialog \
-        import SLDPanel
+            import SLDPanel
         sld_data = pf_data1d(x, y)
         sld_data.name = 'SLD'
@@ -1791,5 +1794,5 @@
         self.structurebox.Disable()
         self.formfactorbox.Clear()
-        if mod_cat == None:
+        if mod_cat is None:
             return
         m_list = []
@@ -1853,5 +1856,5 @@
         """
         tcrtl = event.GetEventObject()
-        #Clear msg if previously shown.
+        # Clear msg if previously shown.
         msg = ""
         wx.PostEvent(self.parent, StatusEvent(status=msg))
@@ -1872,5 +1875,5 @@
                     tcrtl.SetBackgroundColour("pink")
                     msg = "Model Error: wrong value entered: %s" % \
-                                    sys.exc_info()[1]
+                          sys.exc_info()[1]
                     wx.PostEvent(self.parent, StatusEvent(status=msg))
                     return
@@ -1880,6 +1883,6 @@
                 wx.PostEvent(self.parent, StatusEvent(status=msg))
                 return
-            #Check if # of points for theory model are valid(>0).
-            if self.npts != None:
+            # Check if # of points for theory model are valid(>0).
+            if self.npts is not None:
                 if check_float(self.npts):
                     temp_npts = float(self.npts.GetValue())
@@ -1897,5 +1900,5 @@
         wx.PostEvent(self.parent, event)
         self.state_change = False
-        #Draw the model for a different range
+        # Draw the model for a different range
         if not self.data.is_data:
             self.create_default_data()
@@ -1908,5 +1911,5 @@
 
         tcrtl = event.GetEventObject()
-        #Clear msg if previously shown.
+        # Clear msg if previously shown.
         msg = ""
         wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
@@ -1929,5 +1932,5 @@
                     tcrtl.SetBackgroundColour("pink")
                     msg = "Model Error: wrong value entered: %s" % \
-                                        sys.exc_info()[1]
+                          sys.exc_info()[1]
                     wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
                     return
@@ -1937,5 +1940,5 @@
                 wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
                 return
-            #Check if # of points for theory model are valid(>0).
+            # Check if # of points for theory model are valid(>0).
             if self.Npts_total.IsEditable():
                 if check_float(self.Npts_total):
@@ -1955,5 +1958,5 @@
         wx.PostEvent(self.parent, event)
         self.state_change = False
-        #Draw the model for a different range
+        # Draw the model for a different range
         self.create_default_data()
         self._draw_model()
@@ -1963,10 +1966,10 @@
         call back for model selection
         """
-        ## reset dictionary containing reference to dispersion
+        # reset dictionary containing reference to dispersion
         self._disp_obj_dict = {}
         self.disp_cb_dict = {}
         self.temp_multi_functional = False
         f_id = self.formfactorbox.GetCurrentSelection()
-        #For MAC
+        # For MAC
         form_factor = None
         if f_id >= 0:
@@ -1975,5 +1978,5 @@
         if form_factor is None or \
             not hasattr(form_factor, 'is_form_factor') or \
-            not form_factor.is_form_factor:
+                not form_factor.is_form_factor:
             self.structurebox.Hide()
             self.text2.Hide()
@@ -1987,5 +1990,5 @@
             self.text2.Enable()
 
-        if form_factor != None:
+        if form_factor is not None:
             # set multifactor for Mutifunctional models
             if form_factor.is_multiplicity_model:
@@ -1995,5 +1998,5 @@
                 self._set_multfactor_combobox(multiplicity)
                 self._show_multfactor_combobox()
-                #ToDo:  this info should be called directly from the model
+                # ToDo: this info should be called directly from the model
                 text = form_factor.multiplicity_info[1]  # 'No. of Shells: '
 
@@ -2004,5 +2007,5 @@
 
                 self.multi_factor = self.multifactorbox.GetClientData(m_id)
-                if self.multi_factor == None:
+                if self.multi_factor is None:
                     self.multi_factor = 0
                 self.multifactorbox.SetSelection(m_id)
@@ -2010,5 +2013,5 @@
                 text = ''
                 if form_factor.multiplicity_info[0] == \
-                                        len(form_factor.multiplicity_info[2]):
+                        len(form_factor.multiplicity_info[2]):
                     text = form_factor.multiplicity_info[2][self.multi_factor]
                 self.mutifactor_text1.SetLabel(text)
@@ -2031,5 +2034,5 @@
         struct_factor = self.structurebox.GetClientData(s_id)
 
-        if  struct_factor != None:
+        if struct_factor is not None:
             from sasmodels.sasview_model import MultiplicationModel
             self.model = MultiplicationModel(form_factor(self.multi_factor),
@@ -2038,5 +2041,5 @@
             if len(form_factor.non_fittable) > 0:
                 self.temp_multi_functional = True
-        elif form_factor != None:
+        elif form_factor is not None:
             if self.multi_factor is not None:
                 self.model = form_factor(self.multi_factor)
@@ -2053,5 +2056,5 @@
         else:
             self._has_magnetic = False
-        ## post state to fit panel
+        # post state to fit panel
         self.state.parameters = []
         self.state.model = self.model
@@ -2063,5 +2066,4 @@
         self.Layout()
 
-
     def _validate_qrange(self, qmin_ctrl, qmax_ctrl):
         """
@@ -2083,5 +2085,5 @@
             qmax = float(qmax_ctrl.GetValue())
             if qmin < qmax:
-                #Make sure to set both colours white.
+                # Make sure to set both colours white.
                 qmin_ctrl.SetBackgroundColour(wx.WHITE)
                 qmin_ctrl.Refresh()
@@ -2103,8 +2105,8 @@
         If valid, setvalues Npts_fit otherwise post msg.
         """
-        #default flag
+        # default flag
         flag = True
         # Theory
-        if self.data == None and self.enable2D:
+        if self.data is None and self.enable2D:
             return flag
         for data in self.data_list:
@@ -2112,7 +2114,7 @@
             radius = numpy.sqrt(data.qx_data * data.qx_data +
                                 data.qy_data * data.qy_data)
-            #get unmasked index
+            # get unmasked index
             index_data = (float(self.qmin.GetValue()) <= radius) & \
-                            (radius <= float(self.qmax.GetValue()))
+                         (radius <= float(self.qmax.GetValue()))
             index_data = (index_data) & (data.mask)
             index_data = (index_data) & (numpy.isfinite(data.data))
@@ -2130,5 +2132,5 @@
                 flag = False
             else:
-                self.Npts_fit.SetValue(str(len(index_data[index_data == True])))
+                self.Npts_fit.SetValue(str(len(index_data[index_data is True])))
                 self.fitrange = True
 
@@ -2140,15 +2142,15 @@
         If valid, setvalues Npts_fit otherwise post msg.
         """
-        #default flag
+        # default flag
         flag = True
         # Theory
-        if self.data == None:
+        if self.data is None:
             return flag
         for data in self.data_list:
             # q value from qx and qy
             radius = data.x
-            #get unmasked index
+            # get unmasked index
             index_data = (float(self.qmin.GetValue()) <= radius) & \
-                            (radius <= float(self.qmax.GetValue()))
+                         (radius <= float(self.qmax.GetValue()))
             index_data = (index_data) & (numpy.isfinite(data.y))
 
@@ -2165,5 +2167,5 @@
                 flag = False
             else:
-                self.Npts_fit.SetValue(str(len(index_data[index_data == True])))
+                self.Npts_fit.SetValue(str(len(index_data[index_data is True])))
                 self.fitrange = True
 
@@ -2185,5 +2187,5 @@
         is_modified = False
         for item in list:
-            #skip angle parameters for 1D
+            # skip angle parameters for 1D
             if not self.enable2D and item in self.orientation_params:
                 continue
@@ -2230,6 +2232,8 @@
                     max_ctrl.SetBackgroundColour("pink")
                     max_ctrl.Refresh()
-                    #msg = "Invalid fit range for %s: min must be smaller than max"%name
-                    #wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
+                    # msg = "Invalid fit range for %s: min must be smaller
+                    # than max"%name
+                    # wx.PostEvent(self._manager.parent,
+                    # StatusEvent(status=msg))
                     continue
 
@@ -2249,5 +2253,5 @@
                     # The configuration has changed but it won't change the
                     # computed curve so no need to set is_modified to True
-                    #is_modified = True
+                    # is_modified = True
                     self.model.details[name][1:3] = low, high
 
@@ -2267,6 +2271,6 @@
         Redraw the model with the default dispersity (Gaussian)
         """
-        ## On selction if no model exists.
-        if self.model == None:
+        # On selction if no model exists.
+        if self.model is None:
             self.disable_disp.SetValue(True)
             msg = "Please select a Model first..."
@@ -2278,5 +2282,5 @@
         self._reset_dispersity()
 
-        if self.model == None:
+        if self.model is None:
             self.model_disp.Hide()
             self.sizer4_4.Clear(True)
@@ -2284,5 +2288,5 @@
 
         if self.enable_disp.GetValue():
-            ## layout for model containing no dispersity parameters
+            # layout for model containing no dispersity parameters
 
             self.disp_list = self.model.getDispParamList()
@@ -2291,23 +2295,23 @@
                 self._layout_sizer_noDipers()
             else:
-                ## set gaussian sizer
+                # set gaussian sizer
                 self._on_select_Disp(event=None)
         else:
             self.sizer4_4.Clear(True)
 
-        ## post state to fit panel
+        # post state to fit panel
         self.save_current_state()
-        if event != None:
+        if event is not None:
             event = PageInfoEvent(page=self)
             wx.PostEvent(self.parent, event)
-        #draw the model with the current dispersity
-
-        #Wojtek P, Oct 8, 2016: Calling draw_model seems to be unessecary.
-        #By comenting it we save an extra Iq calculation
-        #self._draw_model()
-
-        ## Need to use FitInside again here to replace the next four lines.
-        ## Otherwised polydispersity off does not resize the scrollwindow.
-        ## PDB Nov 28, 2015
+        # draw the model with the current dispersity
+
+        # Wojtek P, Oct 8, 2016: Calling draw_model seems to be unessecary.
+        # By comenting it we save an extra Iq calculation
+        # self._draw_model()
+
+        # Need to use FitInside again here to replace the next four lines.
+        # Otherwised polydispersity off does not resize the scrollwindow.
+        # PDB Nov 28, 2015
         self.FitInside()
 #        self.sizer4_4.Layout()
@@ -2353,5 +2357,5 @@
         self.weights = {}
 
-        #from sas.models.dispersion_models import GaussianDispersion
+        # from sas.models.dispersion_models import GaussianDispersion
         from sasmodels.weights import GaussianDispersion
         if len(self.disp_cb_dict) == 0:
@@ -2374,5 +2378,5 @@
                     logging.error(traceback.format_exc())
 
-        ## save state into
+        # save state into
         self.save_current_state()
         self.Layout()
@@ -2386,7 +2390,7 @@
         self._set_sizer_dispersion()
 
-        ## Redraw the model
+        # Redraw the model
         self._draw_model()
-        #self._undo.Enable(True)
+        # self._undo.Enable(True)
         event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
@@ -2403,5 +2407,5 @@
         """
         # get ready for new event
-        if event != None:
+        if event is not None:
             event.Skip()
         # Get event object
@@ -2416,5 +2420,5 @@
             dispersity = disp_box.GetClientData(selection)
 
-            #disp_model =  GaussianDispersion()
+            # disp_model =  GaussianDispersion()
             disp_model = dispersity()
             # Get param names to reset the values of the param
@@ -2429,5 +2433,5 @@
             else:
                 self._del_array_values(name1)
-                #self._reset_array_disp(param_name)
+                # self._reset_array_disp(param_name)
                 self._disp_obj_dict[name1] = disp_model
                 self.model.set_dispersion(param_name, disp_model)
@@ -2513,8 +2517,8 @@
         if path is None:
             self.disp_cb_dict[name].SetValue(False)
-            #self.noDisper_rbox.SetValue(True)
+            # self.noDisper_rbox.SetValue(True)
             return
         self._default_save_location = os.path.dirname(path)
-        if self._manager != None:
+        if self._manager is not None:
             self._manager.parent._default_save_location = \
                              self._default_save_location
@@ -2533,5 +2537,5 @@
         wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
         self._set_array_disp_model(name=name, disp=disp,
-                                    values=values, weights=weights)
+                                   values=values, weights=weights)
         return basename
 
@@ -2552,5 +2556,5 @@
         # Store the object to make it persist outside the
         # scope of this method
-        #TODO: refactor model to clean this up?
+        # TODO: refactor model to clean this up?
         self.state.values = {}
         self.state.weights = {}
@@ -2559,14 +2563,14 @@
 
         # Set the new model as the dispersion object for the
-        #selected parameter
-        #self.model.set_dispersion(p, disp_model)
+        # selected parameter
+        # self.model.set_dispersion(p, disp_model)
         # Store a reference to the weights in the model object
-        #so that
+        # so that
         # it's not lost when we use the model within another thread.
         self.state.model = self.model.clone()
         self.model._persistency_dict[name.split('.')[0]] = \
-                                        [values, weights]
+            [values, weights]
         self.state.model._persistency_dict[name.split('.')[0]] = \
-                                        [values, weights]
+            [values, weights]
 
     def _del_array_values(self, name=None):
@@ -2606,5 +2610,5 @@
             Layout after self._draw_model
         """
-        if ON_MAC == True:
+        if ON_MAC is True:
             time.sleep(1)
 
@@ -2628,6 +2632,6 @@
         """
         flag = True
-        ##For 3 different cases: Data2D, Data1D, and theory
-        if self.model == None:
+        # For 3 different cases: Data2D, Data1D, and theory
+        if self.model is None:
             msg = "Please select a model first..."
             wx.MessageBox(msg, 'Info')
@@ -2641,8 +2645,8 @@
             self.qmin_x = data_min
             self.qmax_x = math.sqrt(x * x + y * y)
-            #self.data.mask = numpy.ones(len(self.data.data),dtype=bool)
+            # self.data.mask = numpy.ones(len(self.data.data),dtype=bool)
             # check smearing
             if not self.disable_smearer.GetValue():
-                ## set smearing value whether or
+                # set smearing value whether or
                 # not the data contain the smearing info
                 if self.pinhole_smearer.GetValue():
@@ -2651,5 +2655,5 @@
                     flag = True
 
-        elif self.data == None:
+        elif self.data is None:
             self.qmin_x = _QMIN_DEFAULT
             self.qmax_x = _QMAX_DEFAULT
@@ -2662,5 +2666,5 @@
             # check smearing
             if not self.disable_smearer.GetValue():
-                ## set smearing value whether or
+                # set smearing value whether or
                 # not the data contain the smearing info
                 if self.slit_smearer.GetValue():
@@ -2673,5 +2677,5 @@
             flag = False
 
-        if flag == False:
+        if flag is False:
             msg = "Cannot Plot :Must enter a number!!!  "
             wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
@@ -2690,5 +2694,5 @@
         self.state.qmax = self.qmax_x
 
-        #reset the q range values
+        # reset the q range values
         self._reset_plotting_range(self.state)
         self._draw_model()
@@ -2731,5 +2735,5 @@
                 logging.error(traceback.format_exc())
         # Make sure the resduals plot goes to the last
-        if res_item != None:
+        if res_item is not None:
             graphs.append(res_item[0])
             canvases.append(res_item[1])
@@ -2750,10 +2754,10 @@
         the # to the browser.
 
-        :param evt: on Help Button pressed event
-        """
-
-        if self.model != None:
+        :param event: on Help Button pressed event
+        """
+
+        if self.model is not None:
             name = self.formfactorbox.GetValue()
-            _TreeLocation = 'user/models/'+ name.lower()+'.html'
+            _TreeLocation = 'user/models/' + name.lower()+'.html'
             _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation,
                                               "", name + " Help")
@@ -2762,5 +2766,4 @@
             _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation,
                                               "", "General Model Help")
-
 
     def on_model_help_clicked(self, event):
@@ -2774,8 +2777,8 @@
         give the message that none is available.
 
-        :param evt: on Description Button pressed event
-        """
-
-        if self.model == None:
+        :param event: on Description Button pressed event
+        """
+
+        if self.model is None:
             name = 'index.html'
         else:
@@ -2784,6 +2787,6 @@
         msg = 'Model description:\n'
         info = "Info"
-        if self.model != None:
-#                frame.Destroy()
+        if self.model is not None:
+            # frame.Destroy()
             if str(self.model.description).rstrip().lstrip() == '':
                 msg += "Sorry, no information is available for this model."
@@ -2854,10 +2857,10 @@
             for key in self.model.magnetic_params:
                 if key.count('M0') > 0:
-                    #reset mag value to zero fo safety
+                    # reset mag value to zero fo safety
                     self.model.setParam(key, 0.0)
 
         self.Show(False)
         self.set_model_param_sizer(self.model)
-        #self._set_sizer_dispersion()
+        # self._set_sizer_dispersion()
         self.state.magnetic_on = self.magnetic_on
         self.SetupScrolling()
@@ -2874,5 +2877,5 @@
         running "file:///...."
 
-        :param evt: Triggers on clicking ? in polydispersity box
+        :param event: Triggers on clicking ? in polydispersity box
         """
 
@@ -2912,5 +2915,5 @@
         content = 'sasview_parameter_values:'
         # Do it if params exist
-        if  self.parameters != []:
+        if self.parameters:
 
             # go through the parameters
@@ -2956,8 +2959,8 @@
 
         # Do it if params exist
-        if  self.parameters != []:
+        if self.parameters:
 
             for param in self.parameters:
-                content += param[1] #parameter name
+                content += param[1]  # parameter name
                 content += tab
                 content += param[1] + "_err"
@@ -2966,9 +2969,9 @@
             content += crlf
 
-            #row of values and errors...
+            # row of values and errors...
             for param in self.parameters:
-                content += param[2].GetValue() #value
+                content += param[2].GetValue()  # value
                 content += tab
-                content += param[4].GetValue() #error
+                content += param[4].GetValue()  # error
                 content += tab
 
@@ -2976,5 +2979,4 @@
         else:
             return False
-
 
     def get_copy_latex(self):
@@ -2998,5 +3000,5 @@
 
         # Do it if params exist
-        if  self.parameters != []:
+        if self.parameters:
 
             content += '{|'
@@ -3007,5 +3009,5 @@
 
             for index, param in enumerate(self.parameters):
-                content += param[1].replace('_', '\_') #parameter name
+                content += param[1].replace('_', '\_')  # parameter name
                 content += ' & '
                 content += param[1].replace('_', '\_') + "\_err"
@@ -3015,9 +3017,9 @@
             content += crlf
 
-            #row of values and errors...
+            # row of values and errors...
             for index, param in enumerate(self.parameters):
-                content += param[2].GetValue() #parameter value
+                content += param[2].GetValue()  # parameter value
                 content += ' & '
-                content += param[4].GetValue() #parameter error
+                content += param[4].GetValue()  # parameter error
                 if index < len(self.parameters) - 1:
                     content += ' & '
@@ -3030,5 +3032,4 @@
         else:
             return False
-
 
     def set_clipboard(self, content=None):
@@ -3077,5 +3078,5 @@
             # 1D
             else:
-                ## for 1D all parameters except orientation
+                # for 1D all parameters except orientation
                 if not item[1] in orient_param:
                     try:
@@ -3109,7 +3110,6 @@
             except Exception:
                 logging.error(traceback.format_exc())
-            content += name + ',' + str(check) + ',' +\
-                    value + disfunc + ',' + bound_lo + ',' +\
-                    bound_hi + ':'
+            content += name + ',' + str(check) + ',' + value + disfunc + ',' + \
+                       bound_lo + ',' + bound_hi + ':'
 
         return content
@@ -3189,5 +3189,5 @@
 
         # Do it if params exist
-        if  self.parameters != []:
+        if self.parameters:
             # go through the parameters
             self._get_paste_helper(self.parameters,
@@ -3237,5 +3237,5 @@
                                 pd = int(pd)
                         except Exception:
-                            #continue
+                            # continue
                             if not pd and pd != '':
                                 continue
@@ -3265,9 +3265,9 @@
                     else:
                         is_true = None
-                    if is_true != None:
+                    if is_true is not None:
                         item[0].SetValue(is_true)
             # 1D
             else:
-                ## for 1D all parameters except orientation
+                # for 1D all parameters except orientation
                 if not item[1] in orient_param:
                     name = item[1]
@@ -3278,7 +3278,8 @@
                         pd = value[0]
                         if name.count('.') > 0:
-                            # If this is parameter.width, then pd may be a floating
-                            # point value or it may be an array distribution.
-                            # Nothing to do for parameter.npts or parameter.nsigmas.
+                            # If this is parameter.width, then pd may be a
+                            # floating point value or it may be an array
+                            # distribution. Nothing to do for parameter.npts or
+                            # parameter.nsigmas.
                             try:
                                 pd = float(pd)
@@ -3286,5 +3287,5 @@
                                     pd = int(pd)
                             except:
-                                #continue
+                                # continue
                                 if not pd and pd != '':
                                     continue
@@ -3314,5 +3315,5 @@
                         else:
                             is_true = None
-                        if is_true != None:
+                        if is_true is not None:
                             item[0].SetValue(is_true)
 
@@ -3381,5 +3382,5 @@
             logging.error(traceback.format_exc())
             print "Error in BasePage._paste_poly_help: %s" % \
-                                    sys.exc_info()[1]
+                  sys.exc_info()[1]
 
     def _set_disp_cb(self, isarray, item):
@@ -3447,5 +3448,5 @@
         self.categorybox.Clear()
         cat_list = sorted(self.master_category_dict.keys())
-        if not uncat_str in cat_list:
+        if uncat_str not in cat_list:
             cat_list.append(uncat_str)
 
@@ -3457,7 +3458,7 @@
             self.categorybox.SetSelection(0)
         else:
-            self.categorybox.SetSelection(\
+            self.categorybox.SetSelection(
                 self.categorybox.GetSelection())
-        #self._on_change_cat(None)
+        # self._on_change_cat(None)
 
     def _on_change_cat(self, event):
@@ -3467,5 +3468,5 @@
         self.model_name = None
         category = self.categorybox.GetStringSelection()
-        if category == None:
+        if category is None:
             return
         self.model_box.Clear()
@@ -3478,5 +3479,5 @@
         else:
             for (model, enabled) in sorted(self.master_category_dict[category],
-                                      key=lambda name: name[0]):
+                                           key=lambda name: name[0]):
                 if(enabled):
                     self.model_box.Append(model)
@@ -3487,7 +3488,7 @@
         """
         # This should only be called once per fit tab
-        #print "==== Entering _fill_model_sizer"
-        ##Add model function Details button in fitpanel.
-        ##The following 3 lines are for Mac. Let JHC know before modifying...
+        # print "==== Entering _fill_model_sizer"
+        # Add model function Details button in fitpanel.
+        # The following 3 lines are for Mac. Let JHC know before modifying...
         title = "Model"
         self.formfactorbox = None
@@ -3521,43 +3522,43 @@
         self._populate_listbox()
         wx.EVT_COMBOBOX(self.categorybox, wx.ID_ANY, self._show_combox)
-        #self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes',
+        # self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes',
         #                                     style=wx.RB_GROUP)
-        #self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY,
+        # self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY,
         #                                          "Shape-Independent")
-        #self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY,
+        # self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY,
         #                                     "Structure Factor ")
-        #self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY,
+        # self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY,
         #                                     "Uncategorized")
 
-        #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
+        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
         #                   id=self.shape_rbutton.GetId())
-        #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
+        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
         #                    id=self.shape_indep_rbutton.GetId())
-        #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
+        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
         #                    id=self.struct_rbutton.GetId())
-        #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
+        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox,
         #                    id=self.plugin_rbutton.GetId())
-        #MAC needs SetValue
+        # MAC needs SetValue
 
         show_cat_button = wx.Button(self, wx.ID_ANY, "Modify")
         cat_tip = "Modify model categories \n"
         cat_tip += "(also accessible from the menu bar)."
-        show_cat_button.SetToolTip( wx.ToolTip(cat_tip) )
+        show_cat_button.SetToolTip(wx.ToolTip(cat_tip))
         show_cat_button.Bind(wx.EVT_BUTTON, self._on_modify_cat)
         sizer_cat_box.Add(self.categorybox, 1, wx.RIGHT, 3)
-        sizer_cat_box.Add((10,10))
+        sizer_cat_box.Add((10, 10))
         sizer_cat_box.Add(show_cat_button)
-        #self.shape_rbutton.SetValue(True)
+        # self.shape_rbutton.SetValue(True)
 
         sizer_radiobutton = wx.GridSizer(2, 2, 5, 5)
-        #sizer_radiobutton.Add(self.shape_rbutton)
-        #sizer_radiobutton.Add(self.shape_indep_rbutton)
-        sizer_radiobutton.Add((5,5))
+        # sizer_radiobutton.Add(self.shape_rbutton)
+        # sizer_radiobutton.Add(self.shape_indep_rbutton)
+        sizer_radiobutton.Add((5, 5))
         sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 5)
-        #sizer_radiobutton.Add(self.plugin_rbutton)
-        #sizer_radiobutton.Add(self.struct_rbutton)
-#        sizer_radiobutton.Add((5,5))
+        # sizer_radiobutton.Add(self.plugin_rbutton)
+        # sizer_radiobutton.Add(self.struct_rbutton)
+        # sizer_radiobutton.Add((5,5))
         sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT | wx.LEFT, 5)
-#        sizer_radiobutton.Add((5,5))
+        # sizer_radiobutton.Add((5,5))
         sizer_radiobutton.Add(self.model_func, 1, wx.RIGHT, 5)
         sizer_cat.Add(sizer_cat_box, 1, wx.LEFT, 2.5)
@@ -3575,5 +3576,5 @@
         self.formfactorbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY)
         self.formfactorbox.SetToolTip(wx.ToolTip("Select a Model"))
-        if self.model != None:
+        if self.model is not None:
             self.formfactorbox.SetValue(self.model.name)
         self.structurebox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY)
@@ -3584,8 +3585,8 @@
         wx.EVT_COMBOBOX(self.structurebox, wx.ID_ANY, self._on_select_model)
         wx.EVT_COMBOBOX(self.multifactorbox, wx.ID_ANY, self._on_select_model)
-        ## check model type to show sizer
-        if self.model != None:
+        # check model type to show sizer
+        if self.model is not None:
             print "_set_model_sizer_selection: disabled."
-            #self._set_model_sizer_selection(self.model)
+            # self._set_model_sizer_selection(self.model)
 
         sizer_selection.Add(self.text1)
@@ -3682,4 +3683,5 @@
         """
 
+
 class ModelTextCtrl(wx.TextCtrl):
     """
@@ -3694,7 +3696,7 @@
 
     """
-    ## Set to True when the mouse is clicked while whole string is selected
+    # Set to True when the mouse is clicked while whole string is selected
     full_selection = False
-    ## Call back for EVT_SET_FOCUS events
+    # Call back for EVT_SET_FOCUS events
     _on_set_focus_callback = None
 
@@ -3718,11 +3720,11 @@
             if set_focus_callback is None else set_focus_callback
         self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus)
-        self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus \
-            if kill_focus_callback is None else kill_focus_callback)
-        self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter \
-            if text_enter_callback is None else text_enter_callback)
+        self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus
+        if kill_focus_callback is None else kill_focus_callback)
+        self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter
+        if text_enter_callback is None else text_enter_callback)
         if not ON_MAC:
-            self.Bind(wx.EVT_LEFT_UP, self._highlight_text \
-                if mouse_up_callback is None else mouse_up_callback)
+            self.Bind(wx.EVT_LEFT_UP, self._highlight_text
+            if mouse_up_callback is None else mouse_up_callback)
 
     def _on_set_focus(self, event):
@@ -3764,3 +3766,3 @@
 
         event.Skip()
-        #pass
+        # pass
