Index: src/sas/sasgui/guiframe/data_panel.py
===================================================================
--- src/sas/sasgui/guiframe/data_panel.py	(revision 998ca90ad87500d7d5fb3f4eb13105752a2f2952)
+++ src/sas/sasgui/guiframe/data_panel.py	(revision c8e19964f2dda929ccae8237e7b140a906cdf134)
@@ -1,10 +1,10 @@
 ################################################################################
-#This software was developed by the University of Tennessee as part of the
-#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-#project funded by the US National Science Foundation.
+# This software was developed by the University of Tennessee as part of the
+# Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+# project funded by the US National Science Foundation.
 #
-#See the license text in license.txt
+# See the license text in license.txt
 #
-#copyright 2010, University of Tennessee
+# copyright 2010, University of Tennessee
 ################################################################################
 """
@@ -14,16 +14,7 @@
 from wx.build import build_options
 
-# Check version
-toks = str(wx.__version__).split('.')
-if int(toks[1]) < 9:
-    if int(toks[2]) < 12:
-        wx_version = 811
-    else:
-        wx_version = 812
-else:
-    wx_version = 900
 import sys
 from wx.lib.scrolledpanel import ScrolledPanel
-import  wx.lib.agw.customtreectrl as CT
+import wx.lib.agw.customtreectrl as CT
 from sas.sasgui.guiframe.dataFitting import Data1D
 from sas.sasgui.guiframe.dataFitting import Data2D
@@ -36,9 +27,19 @@
 from sas.sasgui.guiframe.events import NewBatchEvent
 from sas.sascalc.dataloader.loader import Loader
-#from sas.sasgui.guiframe.local_perspectives.plotting.masking \
+# from sas.sasgui.guiframe.local_perspectives.plotting.masking \
 #    import FloatPanel as QucikPlotDialog
-from sas.sasgui.guiframe.local_perspectives.plotting.SimplePlot import PlotFrame \
-        as QucikPlotDialog
+from sas.sasgui.guiframe.local_perspectives.plotting.SimplePlot \
+    import PlotFrame as QucikPlotDialog
 import sas.sasgui.guiframe.config as config
+
+# Check version
+toks = str(wx.__version__).split('.')
+if int(toks[1]) < 9:
+    if int(toks[2]) < 12:
+        wx_version = 811
+    else:
+        wx_version = 812
+else:
+    wx_version = 900
 
 extension_list = []
@@ -49,5 +50,5 @@
 APPLICATION_WLIST = config.APPLICATION_WLIST
 
-#Control panel width
+# Control panel width
 if sys.platform.count("win32") > 0:
     PANEL_WIDTH = 235
@@ -65,6 +66,6 @@
     IS_MAC = True
 
-STYLE_FLAG = wx.RAISED_BORDER|CT.TR_HAS_BUTTONS| CT.TR_HIDE_ROOT|\
-                    wx.WANTS_CHARS|CT.TR_HAS_VARIABLE_ROW_HEIGHT
+STYLE_FLAG = wx.RAISED_BORDER | CT.TR_HAS_BUTTONS | CT.TR_HIDE_ROOT |\
+                    wx.WANTS_CHARS | CT.TR_HAS_VARIABLE_ROW_HEIGHT
 
 
@@ -74,5 +75,5 @@
     """
     def __init__(self, parent, *args, **kwds):
-        #agwstyle is introduced in wx.2.8.11 but is not working for mac
+        # agwstyle is introduced in wx.2.8.11 but is not working for mac
         if IS_MAC and wx_version < 812:
             try:
@@ -114,4 +115,5 @@
             return 0
 
+
 class DataPanel(ScrolledPanel, PanelBase):
     """
@@ -119,13 +121,14 @@
     interact with data.
     """
-    ## Internal name for the AUI manager
+    # Internal name for the AUI manager
     window_name = "Data Panel"
-    ## Title to appear on top of the window
+    # Title to appear on top of the window
     window_caption = "Data Explorer"
-    #type of window
+    # type of window
     window_type = "Data Panel"
-    ## Flag to tell the GUI manager that this panel is not
+    # Flag to tell the GUI manager that this panel is not
     #  tied to any perspective
-    #ALWAYS_ON = True
+    # ALWAYS_ON = True
+
     def __init__(self, parent,
                  list=None,
@@ -133,13 +136,13 @@
                  id=-1,
                  list_of_perspective=None, manager=None, *args, **kwds):
-        #kwds['size'] = size
-        #kwds['style'] = STYLE_FLAG
+        # kwds['size'] = size
+        # kwds['style'] = STYLE_FLAG
         ScrolledPanel.__init__(self, parent=parent, id=id, *args, **kwds)
         PanelBase.__init__(self, parent)
         self.SetupScrolling()
-        #Set window's font size
+        # Set window's font size
         self.SetWindowVariant(variant=FONT_VARIANT)
         self.loader = Loader()
-        #Default location
+        # Default location
         self._default_save_location = None
         self.all_data1d = True
@@ -159,5 +162,5 @@
         self.tree_ctrl_theory = None
         self.perspective_cbox = None
-        ## Create context menu for page
+        # Create context menu for page
         self.data_menu = None
         self.popUpMenu = None
@@ -165,5 +168,5 @@
         self.editmask_id = None
         # Default attr
-        self.vbox  = None
+        self.vbox = None
         self.sizer1 = None
         self.sizer2 = None
@@ -210,5 +213,5 @@
         """
         w, h = self.parent.GetSize()
-        self.vbox  = wx.BoxSizer(wx.VERTICAL)
+        self.vbox = wx.BoxSizer(wx.VERTICAL)
         self.sizer1 = wx.BoxSizer(wx.VERTICAL)
         self.sizer1.SetMinSize(wx.Size(w/13, h*2/5))
@@ -219,9 +222,9 @@
         self.sizer5 = wx.BoxSizer(wx.VERTICAL)
 
-        self.vbox.Add(self.sizer5, 0, wx.EXPAND|wx.ALL, 1)
-        self.vbox.Add(self.sizer1, 1, wx.EXPAND|wx.ALL, 0)
-        self.vbox.Add(self.sizer2, 0, wx.EXPAND|wx.ALL, 1)
-        self.vbox.Add(self.sizer3, 0, wx.EXPAND|wx.ALL, 10)
-        #self.vbox.Add(self.sizer4, 0, wx.EXPAND|wx.ALL,5)
+        self.vbox.Add(self.sizer5, 0, wx.EXPAND | wx.ALL, 1)
+        self.vbox.Add(self.sizer1, 1, wx.EXPAND | wx.ALL, 0)
+        self.vbox.Add(self.sizer2, 0, wx.EXPAND | wx.ALL, 1)
+        self.vbox.Add(self.sizer3, 0, wx.EXPAND | wx.ALL, 10)
+        # self.vbox.Add(self.sizer4, 0, wx.EXPAND|wx.ALL,5)
 
         self.SetSizer(self.vbox)
@@ -235,9 +238,9 @@
         self.selection_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)
         list_of_options = ['Select all Data',
-                            'Unselect all Data',
+                           'Unselect all Data',
                            'Select all Data 1D',
                            'Unselect all Data 1D',
                            'Select all Data 2D',
-                           'Unselect all Data 2D' ]
+                           'Unselect all Data 2D']
         for option in list_of_options:
             self.selection_cbox.Append(str(option))
@@ -245,7 +248,6 @@
         wx.EVT_COMBOBOX(self.selection_cbox, -1, self._on_selection_type)
         self.sizer5.AddMany([(select_txt, 0, wx.ALL, 5),
-                            (self.selection_cbox, 0, wx.ALL,5)])
+                            (self.selection_cbox, 0, wx.ALL, 5)])
         self.enable_selection()
-
 
     def _on_selection_type(self, event):
@@ -257,5 +259,5 @@
             self.tree_ctrl.CheckItem(data_ctrl, check_value)
             if data_ctrl.HasChildren():
-                if check_value == True and not control.IsExpanded():
+                if check_value and not control.IsExpanded():
                     # Only select children if control is expanded
                     # Always deselect children, regardless (see ticket #259)
@@ -299,5 +301,5 @@
         Layout widgets related to buttons
         """
-        #Load Data Button
+        # Load Data Button
         self.bt_add = wx.Button(self, wx.NewId(), "Load Data",
                                 size=(BUTTON_WIDTH, -1))
@@ -305,19 +307,19 @@
         wx.EVT_BUTTON(self, self.bt_add.GetId(), self._load_data)
 
-        #Delete Data Button
+        # Delete Data Button
         self.bt_remove = wx.Button(self, wx.NewId(), "Delete Data",
-         size=(BUTTON_WIDTH, -1))
+                                   size=(BUTTON_WIDTH, -1))
         self.bt_remove.SetToolTipString("Delete data from the application")
         wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove)
 
-        #Send data to perspective button
+        # Send data to perspective button
         self.bt_import = wx.Button(self, wx.NewId(), "Send To",
-                                    size=(BUTTON_WIDTH, -1))
+                                   size=(BUTTON_WIDTH, -1))
         self.bt_import.SetToolTipString("Send Data set to active perspective")
         wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import)
 
-        #Choose perspective to be send data to combo box
+        # Choose perspective to be send data to combo box
         self.perspective_cbox = wx.ComboBox(self, -1,
-                                style=wx.CB_READONLY)
+                                            style=wx.CB_READONLY)
         if not IS_MAC:
             self.perspective_cbox.SetMinSize((BUTTON_WIDTH*1.6, -1))
@@ -325,12 +327,12 @@
                         self._on_perspective_selection)
 
-        #Append data to current Graph Button
+        # Append data to current Graph Button
         self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To",
                                         size=(BUTTON_WIDTH, -1))
-        self.bt_append_plot.SetToolTipString( \
-                                "Plot the selected data in the active panel")
+        self.bt_append_plot.SetToolTipString(
+            "Plot the selected data in the active panel")
         wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot)
 
-        #Create a new graph and send data to that new graph button
+        # Create a new graph and send data to that new graph button
         self.bt_plot = wx.Button(self, wx.NewId(), "New Plot",
                                  size=(BUTTON_WIDTH, -1))
@@ -338,5 +340,5 @@
         wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot)
 
-        #Freeze current theory button - becomes a data set and stays on graph
+        # Freeze current theory button - becomes a data set and stays on graph
         self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze Theory",
                                    size=(BUTTON_WIDTH, -1))
@@ -347,5 +349,5 @@
         wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze)
 
-        #select plot to send to combo box (blank if no data)
+        # select plot to send to combo box (blank if no data)
         if sys.platform == 'darwin':
             self.cb_plotpanel = wx.ComboBox(self, -1,
@@ -353,13 +355,13 @@
         else:
             self.cb_plotpanel = wx.ComboBox(self, -1,
-                                            style=wx.CB_READONLY|wx.CB_SORT)
+                                            style=wx.CB_READONLY | wx.CB_SORT)
         wx.EVT_COMBOBOX(self.cb_plotpanel, -1, self._on_plot_selection)
         self.cb_plotpanel.Disable()
 
-        #Help button
+        # Help button
         self.bt_help = wx.Button(self, wx.NewId(), "HELP",
                                  size=(BUTTON_WIDTH, -1))
         self.bt_help.SetToolTipString("Help for the Data Explorer.")
-        wx.EVT_BUTTON(self,self.bt_help.GetId(), self.on_help)
+        wx.EVT_BUTTON(self, self.bt_help.GetId(), self.on_help)
 
         self.sizer3.AddMany([(self.bt_add),
@@ -373,10 +375,10 @@
                              (self.bt_append_plot),
                              (self.cb_plotpanel,
-                              wx.EXPAND|wx.ADJUST_MINSIZE, 5),
+                              wx.EXPAND | wx.ADJUST_MINSIZE, 5),
                              ((5, 5)),
                              ((5, 5)),
-                             (self.bt_import, 0, wx.EXPAND|wx.RIGHT, 5),
+                             (self.bt_import, 0, wx.EXPAND | wx.RIGHT, 5),
                              (self.perspective_cbox,
-                              wx.EXPAND|wx.ADJUST_MINSIZE, 5),
+                              wx.EXPAND | wx.ADJUST_MINSIZE, 5),
                              ((10, 10)),
                              (self.sizer4),
@@ -401,7 +403,7 @@
         self.rb_batch_mode = wx.RadioButton(self, -1, 'Batch Mode')
         self.Bind(wx.EVT_RADIOBUTTON, self.on_single_mode,
-                     id=self.rb_single_mode.GetId())
+                  id=self.rb_single_mode.GetId())
         self.Bind(wx.EVT_RADIOBUTTON, self.on_batch_mode,
-                   id=self.rb_batch_mode.GetId())
+                  id=self.rb_batch_mode.GetId())
 
         self.rb_single_mode.SetValue(not self.parent.batch_on)
@@ -433,11 +435,11 @@
         """
         data = None
-        #selection = event.GetSelection()
+        # selection = event.GetSelection()
         id, _, _ = self.FindFocus().GetSelection().GetData()
         data_list, theory_list = \
-                        self.parent.get_data_manager().get_by_id(id_list=[id])
+            self.parent.get_data_manager().get_by_id(id_list=[id])
         if data_list:
             data = data_list.values()[0]
-        if data == None:
+        if data is None:
             data = theory_list.values()[0][0]
         return data
@@ -461,5 +463,5 @@
         data = self._get_data_selection(event)
         from sas.sasgui.guiframe.local_perspectives.plotting.masking \
-        import FloatPanel as Float3dDialog
+            import FloatPanel as Float3dDialog
 
         panel = Float3dDialog(base=self, data=data,
@@ -476,13 +478,13 @@
         else:
             dimension = 1
-        #panel = QucikPlotDialog(base=self, data=data,
+        # panel = QucikPlotDialog(base=self, data=data,
         #                        dimension=dimension, id=wx.NewId())
         frame = QucikPlotDialog(self, -1, "Plot " + data.name, 'log_{10}')
         self.parent.put_icon(frame)
         frame.add_plot(data)
-        #frame.SetTitle(title)
+        # frame.SetTitle(title)
         frame.Show(True)
         frame.SetFocus()
-        #panel.ShowModal()
+        # panel.ShowModal()
 
     def on_data_info(self, event):
@@ -501,10 +503,10 @@
         """
         data = self._get_data_selection(event)
-        #path = None
+        # path = None
         default_name = data.name
         if default_name.count('.') > 0:
             default_name = default_name.split('.')[0]
         default_name += "_out"
-        if self.parent != None:
+        if self.parent is not None:
             if issubclass(data.__class__, Data1D):
                 self.parent.save_data1d(data, default_name)
@@ -523,5 +525,5 @@
         self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item)
         self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_MENU, self.on_right_click_data)
-        ## Create context menu for page
+        # Create context menu for page
         self.data_menu = wx.Menu()
         id = wx.NewId()
@@ -558,13 +560,13 @@
         tree_ctrl_theory_label.SetForegroundColour('blue')
         self.tree_ctrl_theory = DataTreeCtrl(parent=self,
-                                                    style=wx.SUNKEN_BORDER)
+                                             style=wx.SUNKEN_BORDER)
         self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKING,
-                                                    self.on_check_item)
+                                   self.on_check_item)
         self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_MENU,
                                    self.on_right_click_theory)
         self.sizer1.Add(tree_ctrl_label, 0, wx.LEFT, 10)
-        self.sizer1.Add(self.tree_ctrl, 1, wx.EXPAND|wx.ALL, 10)
+        self.sizer1.Add(self.tree_ctrl, 1, wx.EXPAND | wx.ALL, 10)
         self.sizer1.Add(tree_ctrl_theory_label, 0,  wx.LEFT, 10)
-        self.sizer1.Add(self.tree_ctrl_theory, 1, wx.EXPAND|wx.ALL, 10)
+        self.sizer1.Add(self.tree_ctrl_theory, 1, wx.EXPAND | wx.ALL, 10)
 
     def on_right_click_theory(self, event):
@@ -588,10 +590,10 @@
         Allow Editing Data
         """
-        #selection = event.GetSelection()
+        # selection = event.GetSelection()
         is_data = True
         try:
             id, data_class_name, _ = self.tree_ctrl.GetSelection().GetData()
             data_list, _ = \
-                        self.parent.get_data_manager().get_by_id(id_list=[id])
+                self.parent.get_data_manager().get_by_id(id_list=[id])
             if not data_list:
                 is_data = False
@@ -610,9 +612,8 @@
         """
         # Skipping the save state functionality for release 0.9.0
-        #return
+        # return
         pos = event.GetPosition()
         pos = self.ScreenToClient(pos)
         self.PopupMenu(self.popUpMenu, pos)
-
 
     def on_check_item(self, event):
@@ -636,7 +637,7 @@
         if self.parent is None or \
             not hasattr(self.parent, "get_current_perspective") or \
-            len(self.list_of_perspective) == 0:
+                        len(self.list_of_perspective) == 0:
             return
-        if self.parent is not None and self.perspective_cbox  is not None:
+        if self.parent is not None and self.perspective_cbox is not None:
             for plug in self.list_of_perspective:
                 if plug.get_perspective():
@@ -666,24 +667,27 @@
                     s_path = str(path)
                     if state_id not in self.list_cb_data:
-                        #new state
+                        # new state
                         data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,
-                                        0, data_name, ct_type=1,
+                                                           0, data_name,
+                                                           ct_type=1,
                                         data=(data_id, data_class, state_id))
                         data_c.Check(True)
                         d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info')
                         d_t_c = self.tree_ctrl.AppendItem(d_i_c,
-                                                      'Title: %s' % data_title)
+                                                          'Title: %s' %
+                                                          data_title)
                         r_n_c = self.tree_ctrl.AppendItem(d_i_c,
-                                                      'Run: %s' % data_run)
+                                                          'Run: %s' % data_run)
                         i_c_c = self.tree_ctrl.AppendItem(d_i_c,
-                                                      'Type: %s' % data_class)
+                                                          'Type: %s' %
+                                                          data_class)
                         p_c_c = self.tree_ctrl.AppendItem(d_i_c,
-                                                      "Path: '%s'" % s_path)
+                                                          "Path: '%s'" % s_path)
                         d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process')
 
                         for process in process_list:
-                            process_str = str(process).replace('\n',' ')
-                            if len(process_str)>20:
-                                process_str = process_str[:20]+' [...]'
+                            process_str = str(process).replace('\n', ' ')
+                            if len(process_str) > 20:
+                                process_str = process_str[:20] + ' [...]'
                             self.tree_ctrl.AppendItem(d_p_c, process_str)
                         theory_child = self.tree_ctrl.AppendItem(data_c,
@@ -698,6 +702,6 @@
                                                        theory_child]
                     else:
-                        data_ctrl_list =  self.list_cb_data[state_id]
-                        #This state is already display replace it contains
+                        data_ctrl_list = self.list_cb_data[state_id]
+                        # This state is already display replace it contains
                         data_c, d_i_c, d_t_c, r_n_c,  i_c_c, p_c_c, d_p_c, _ \
                                 = data_ctrl_list
@@ -713,5 +717,5 @@
                             if not process.is_empty():
                                 _ = self.tree_ctrl.AppendItem(d_p_c,
-                                                              process.single_line_desc())
+                                                    process.single_line_desc())
                 wx.CallAfter(self.append_theory, state_id, theory_list)
             # Sort by data name
@@ -757,5 +761,4 @@
                                        theory_list=theory_list)
 
-
     def append_theory_helper(self, tree, root, state_id, theory_list):
         """
@@ -763,5 +766,5 @@
         """
         if state_id in self.list_cb_theory.keys():
-            #update current list of theory for this data
+            # update current list of theory for this data
             theory_list_ctrl = self.list_cb_theory[state_id]
 
@@ -777,9 +780,9 @@
                     theory_class = theory_data.__class__.__name__
                     theory_id = theory_data.id
-                    #if theory_state is not None:
+                    # if theory_state is not None:
                     #    name = theory_state.model.name
                     temp = (theory_id, theory_class, state_id)
                 if theory_id not in theory_list_ctrl:
-                    #add new theory
+                    # add new theory
                     t_child = tree.AppendItem(root,
                                                     name, ct_type=1, data=temp)
@@ -795,5 +798,5 @@
                                                    t_p_c]
                 else:
-                    #replace theory
+                    # replace theory
                     t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id]
                     tree.SetItemText(t_child, name)
@@ -805,5 +808,5 @@
 
         else:
-            #data didn't have a theory associated it before
+            # data didn't have a theory associated it before
             theory_list_ctrl = {}
             for theory_id, item in theory_list.iteritems():
@@ -813,5 +816,5 @@
                     theory_class = theory_data.__class__.__name__
                     theory_id = theory_data.id
-                    #if theory_state is not None:
+                    # if theory_state is not None:
                     #    name = theory_state.model.name
                     temp = (theory_id, theory_class, state_id)
@@ -828,8 +831,6 @@
 
                     theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c]
-                #self.list_cb_theory[data_id] = theory_list_ctrl
+                # self.list_cb_theory[data_id] = theory_list_ctrl
                 self.list_cb_theory[state_id] = theory_list_ctrl
-
-
 
     def set_data_helper(self):
@@ -889,21 +890,20 @@
             wx.PostEvent(self.parent, NewLoadDataEvent())
 
-
-    def on_remove(self, event, msg=""):
+    def on_remove(self, event, prompt=True):
         """
         Get a list of item checked and remove them from the treectrl
         Ask the parent to remove reference to this item
         """
-        if msg == "":
+        if prompt:
             msg = "This operation will delete the data sets checked "
             msg += "and all the dependents."
-        msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK|wx.CANCEL)
-        if msg_box.ShowModal() != wx.ID_OK:
-            return True
+            msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK|wx.CANCEL)
+            if msg_box.ShowModal() != wx.ID_OK:
+                return
 
         data_to_remove, theory_to_remove, _ = self.set_data_helper()
         data_key = []
         theory_key = []
-        #remove  data from treectrl
+        # remove  data from treectrl
         for d_key, item in self.list_cb_data.iteritems():
             data_c, _, _, _,  _, _, _, _ = item
@@ -916,5 +916,5 @@
         # Remove theory from treectrl
         for _, theory_dict in self.list_cb_theory.iteritems():
-            for  key, value in theory_dict.iteritems():
+            for key, value in theory_dict.iteritems():
                 item, _, _ = value
                 if item.IsChecked():
@@ -925,14 +925,14 @@
                     theory_key.append(key)
 
-        #Remove data and related theory references
+        # Remove data and related theory references
         for key in data_key:
             del self.list_cb_data[key]
             if key in theory_key:
                 del self.list_cb_theory[key]
-        #remove theory  references independently of data
+        # remove theory  references independently of data
         for key in theory_key:
             for _, theory_dict in self.list_cb_theory.iteritems():
                 if key in theory_dict:
-                    for  key, value in theory_dict.iteritems():
+                    for key, value in theory_dict.iteritems():
                         item, _, _ = value
                         if item.IsChecked():
@@ -943,5 +943,4 @@
                     del theory_dict[key]
 
-
         self.parent.remove_data(data_id=data_to_remove,
                                   theory_id=theory_to_remove)
@@ -954,5 +953,5 @@
         Get all select data and set them to the current active perspetive
         """
-        if event != None:
+        if event is not None:
             event.Skip()
         data_id, theory_id, state_id = self.set_data_helper()
@@ -986,5 +985,5 @@
         On close
         """
-        if event != None:
+        if event is not None:
             event.Skip()
         # send parent to update menu with no show nor hide action
@@ -1016,5 +1015,5 @@
         from the combobox of the current panel
         """
-        #name = event.name
+        # name = event.name
         caption = event.caption
         if self.cb_plotpanel is not None:
@@ -1034,5 +1033,5 @@
             if name_plot_panel not in self.cb_plotpanel.GetItems():
                 self.cb_plotpanel.Append(name_plot_panel, value)
-            if name != None and name == name_plot_panel:
+            if name is not None and name == name_plot_panel:
                 self.cb_plotpanel.SetStringSelection(name_plot_panel)
                 break
@@ -1060,5 +1059,5 @@
         On source combobox selection
         """
-        if event != None:
+        if event is not None:
             combo = event.GetEventObject()
             event.Skip()
@@ -1107,5 +1106,5 @@
         running "file:///...."
 
-    :param evt: Triggers on clicking the help button
+    :param event: Triggers on clicking the help button
     """
 
@@ -1156,5 +1155,5 @@
         """
         n_t = 0
-        if self.tree_ctrl != None:
+        if self.tree_ctrl is not None:
             n_t = self.tree_ctrl.GetCount()
         if n_t > 0 and len(self.list_of_perspective) > 0:
@@ -1175,7 +1174,7 @@
         n_t = 0
         n_t_t = 0
-        if self.tree_ctrl != None:
+        if self.tree_ctrl is not None:
             n_t = self.tree_ctrl.GetCount()
-        if self.tree_ctrl_theory != None:
+        if self.tree_ctrl_theory is not None:
             n_t_t = self.tree_ctrl_theory.GetCount()
         if n_t + n_t_t <= 0:
@@ -1191,7 +1190,7 @@
         n_t = 0
         n_t_t = 0
-        if self.tree_ctrl != None:
+        if self.tree_ctrl is not None:
             n_t = self.tree_ctrl.GetCount()
-        if self.tree_ctrl_theory != None:
+        if self.tree_ctrl_theory is not None:
             n_t_t = self.tree_ctrl_theory.GetCount()
         if n_t + n_t_t <= 0:
@@ -1215,5 +1214,5 @@
         n_t_t = 0
         n_l = 0
-        if self.tree_ctrl_theory != None:
+        if self.tree_ctrl_theory is not None:
             n_t_t = self.tree_ctrl_theory.GetCount()
         n_l = len(self.list_cb_theory)
@@ -1229,9 +1228,9 @@
         n_t = 0
         n_t_t = 0
-        if self.tree_ctrl != None:
+        if self.tree_ctrl is not None:
             n_t = self.tree_ctrl.GetCount()
-        if self.tree_ctrl_theory != None:
+        if self.tree_ctrl_theory is not None:
             n_t_t = self.tree_ctrl_theory.GetCount()
-        if n_t + n_t_t > 0 and self.selection_cbox != None:
+        if n_t + n_t_t > 0 and self.selection_cbox is not None:
             self.selection_cbox.Enable()
         else:
@@ -1255,5 +1254,4 @@
             #self.bt_remove.Hide()
             self.bt_add.Hide()
-
 
 
@@ -1288,5 +1286,5 @@
         if not data_list or len(data_list) <= 1:
             return
-        #add text
+        # add text
 
         text = "Deleting these file reset some panels.\n"
@@ -1296,11 +1294,11 @@
         iy = 0
         ix = 0
-        #data_count = 0
+        # data_count = 0
         for (data_name, in_use, sub_menu) in range(len(data_list)):
-            if in_use == True:
+            if in_use:
                 ctrl_name = wx.StaticBox(self, -1, str(data_name))
                 ctrl_in_use = wx.StaticBox(self, -1, " is used by ")
                 plug_name = str(sub_menu) + "\n"
-                #ctrl_sub_menu = wx.StaticBox(self, -1, plug_name)
+                # ctrl_sub_menu = wx.StaticBox(self, -1, plug_name)
                 self.sizer.Add(ctrl_name, (iy, ix),
                            (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
@@ -1313,5 +1311,5 @@
             iy += 1
         self._panel.SetSizer(self.sizer)
-        #add sizer
+        # add sizer
         self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
         button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
@@ -1376,7 +1374,7 @@
 
 
-
 from sas.sasgui.guiframe.dataFitting import Theory1D
 from sas.sasgui.guiframe.data_state import DataState
+
 
 class State():
@@ -1392,4 +1390,5 @@
         return self.msg
 
+
 def set_data_state(data=None, path=None, theory=None, state=None):
     """
@@ -1406,5 +1405,5 @@
     app = wx.App()
     try:
-        #list_of_perspective = [('perspective2', False), ('perspective1', True)]
+        # list_of_perspective = [('perspective2', False), ('perspective1', True)]
         data_list1 = {}
         # state 1
@@ -1421,5 +1420,5 @@
         state1 = State()
         data_list1['1'] = set_data_state(data1, path1, theory1, state1)
-        #state 2
+        # state 2
         data1 = Data2D()
         data1.name = "data2"
@@ -1429,5 +1428,5 @@
         theory1.name = "CoreShell 07/24/25"
         path1 = "path2"
-        #state3
+        # state3
         state1 = State()
         data_list1['2'] = set_data_state(data1, path1, theory1, state1)
@@ -1446,9 +1445,9 @@
         process1.data = "07/22/2010"
         data_list1['4'] = set_data_state(data1, path1, theory1, state1)
-        #state 4
+        # state 4
         temp_data_list = {}
         data1.name = "data5 erasing data2"
         temp_data_list['4'] = set_data_state(data1, path1, theory1, state1)
-        #state 5
+        # state 5
         data1 = Data2D()
         data1.name = "data3"
@@ -1483,5 +1482,5 @@
         window.load_data_list(list=temp_data_list)
     except:
-        #raise
+        # raise
         print "error", sys.exc_value
 
Index: src/sas/sasgui/guiframe/gui_manager.py
===================================================================
--- src/sas/sasgui/guiframe/gui_manager.py	(revision a4c24459af9d908f923d5abb9809c6744530b90c)
+++ src/sas/sasgui/guiframe/gui_manager.py	(revision c8e19964f2dda929ccae8237e7b140a906cdf134)
@@ -3,11 +3,11 @@
 """
 ################################################################################
-#This software was developed by the University of Tennessee as part of the
-#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
-#project funded by the US National Science Foundation.
+# This software was developed by the University of Tennessee as part of the
+# Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
+# project funded by the US National Science Foundation.
 #
-#See the license text in license.txtz
+# See the license text in license.txtz
 #
-#copyright 2008, University of Tennessee
+# copyright 2008, University of Tennessee
 ################################################################################
 
@@ -21,5 +21,4 @@
 import warnings
 import re
-warnings.simplefilter("ignore")
 import logging
 import httplib
@@ -49,4 +48,6 @@
 from matplotlib import _pylab_helpers
 
+warnings.simplefilter("ignore")
+
 
 def get_app_dir():
@@ -82,4 +83,5 @@
     return app_path
 
+
 def get_user_directory():
     """
@@ -90,4 +92,5 @@
         os.makedirs(userdir)
     return userdir
+
 
 def _find_local_config(file, path):
@@ -113,5 +116,5 @@
 
 # GUI always starts from the App folder
-#os.chdir(PATH_APP)
+# os.chdir(PATH_APP)
 # Read in the local config, which can either be with the main
 # application or in the installation directory
@@ -128,5 +131,5 @@
     logging.info("found local_config in %s" % PATH_APP)
 
-from sas.sasgui.guiframe.customdir  import SetupCustom
+from sas.sasgui.guiframe.customdir import SetupCustom
 c_conf_dir = SetupCustom().setup_dir(PATH_APP)
 custom_config = _find_local_config('custom_config', c_conf_dir)
@@ -141,5 +144,5 @@
     logging.info("using custom_config from %s" % c_conf_dir)
 
-#read some constants from config
+# read some constants from config
 APPLICATION_STATE_EXTENSION = config.APPLICATION_STATE_EXTENSION
 APPLICATION_NAME = config.__appname__
@@ -169,5 +172,5 @@
     # custom open_path
     open_folder = custom_config.DEFAULT_OPEN_FOLDER
-    if open_folder != None and os.path.isdir(open_folder):
+    if open_folder is not None and os.path.isdir(open_folder):
         DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder)
     else:
@@ -222,4 +225,5 @@
         CHILD_FRAME = wx.Frame
 
+
 class ViewerFrame(PARENT_FRAME):
     """
@@ -235,5 +239,6 @@
         Initialize the Frame object
         """
-        PARENT_FRAME.__init__(self, parent=parent, title=title, pos=pos, size=size)
+        PARENT_FRAME.__init__(self, parent=parent, title=title,
+                              pos=pos, size=size)
         # title
         self.title = title
@@ -256,13 +261,13 @@
         self.path = PATH_APP
         self.application_name = APPLICATION_NAME
-        ## Application manager
+        # Application manager
         self._input_file = None
         self.app_manager = None
         self._mgr = None
-        #add current perpsective
+        # add current perpsective
         self._current_perspective = None
         self._plotting_plugin = None
         self._data_plugin = None
-        #Menu bar and item
+        # Menu bar and item
         self._menubar = None
         self._file_menu = None
@@ -278,5 +283,5 @@
         self._toolbar_menu = None
         self._save_appl_menu = None
-        #tool bar
+        # tool bar
         self._toolbar = None
         # Status bar
@@ -286,11 +291,11 @@
         # plot duck cleanup option
         self.cleanup_plots = CLEANUP_PLOT
-        ## Find plug-ins
+        # Find plug-ins
         # Modify this so that we can specify the directory to look into
         self.plugins = []
-        #add local plugin
+        # add local plugin
         self.plugins += self._get_local_plugins()
         self.plugins += self._find_plugins()
-        ## List of panels
+        # List of panels
         self.panels = {}
         # List of plot panels
@@ -304,20 +309,21 @@
         self.defaultPanel = None
         self.welcome_panel_class = None
-        #panel on focus
+        # panel on focus
         self.panel_on_focus = None
-        #control_panel on focus
+        # control_panel on focus
         self.cpanel_on_focus = None
 
         self.loader = Loader()
-        #data manager
+        # data manager
         self.batch_on = False
         from sas.sasgui.guiframe.data_manager import DataManager
         self._data_manager = DataManager()
-        self._data_panel = None#DataPanel(parent=self)
+        self._data_panel = None  # DataPanel(parent=self)
         if self.panel_on_focus is not None:
-            self._data_panel.set_panel_on_focus(self.panel_on_focus.window_caption)
+            self._data_panel.set_panel_on_focus(
+                self.panel_on_focus.window_caption)
         # list of plot panels in schedule to full redraw
         self.schedule = False
-        #self.callback = True
+        # self.callback = True
         self._idle_count = 0
         self.schedule_full_draw_list = []
@@ -333,5 +339,5 @@
         # Register to status events
         self.Bind(EVT_STATUS, self._on_status_event)
-        #Register add extra data on the same panel event on load
+        # Register add extra data on the same panel event on load
         self.Bind(EVT_PANEL_ON_FOCUS, self.set_panel_on_focus)
         self.Bind(EVT_APPEND_BOOKMARK, self.append_bookmark)
@@ -373,5 +379,5 @@
         # Adjust toolbar height
         toolbar = self.GetToolBar()
-        if toolbar != None:
+        if toolbar is not None:
             _, tb_h = toolbar.GetSizeTuple()
             height -= tb_h
@@ -386,5 +392,5 @@
                     fitpanel = item.fit_panel
 
-        if fitpanel != None:
+        if fitpanel is not None:
             for i in range(0, fitpanel.GetPageCount()):
                 fitpanel.GetPage(i)._populate_listbox()
@@ -413,5 +419,8 @@
         """
         Display value of data into the application grid
-        :param data: dictionary of string and list of items
+        :param data_inputs: dictionary of string and list of items
+        :param details: descriptive string
+        :param file_name: file name
+        :param data_outputs: Data outputs
         """
         self.batch_frame.set_data(data_inputs=data_inputs,
@@ -427,5 +436,5 @@
         """
         path = None
-        if self._default_save_location == None:
+        if self._default_save_location is None:
             self._default_save_location = os.getcwd()
         wildcard = "(*.csv; *.txt)|*.csv; *.txt"
@@ -469,7 +478,7 @@
             line.strip()
             count = 0
-            if separator == None:
+            if separator is None:
                 line.replace('\t', ' ')
-                #found the first line containing the label
+                # found the first line containing the label
                 col_name_toks = line.split()
                 for item in col_name_toks:
@@ -480,5 +489,5 @@
             elif line.find(separator) != -1:
                 if line.count(separator) >= 2:
-                    #found the first line containing the label
+                    # found the first line containing the label
                     col_name_toks = line.split(separator)
                     for item in col_name_toks:
@@ -534,5 +543,5 @@
             separator = ","
         fd.write(str(details))
-        for col_name  in data.keys():
+        for col_name in data.keys():
             fd.write(str(col_name))
             fd.write(separator)
@@ -597,5 +606,5 @@
         Set up custom configuration if exists
         """
-        if custom_config == None:
+        if custom_config is None:
             return
 
@@ -617,5 +626,5 @@
         Set default starting perspective
         """
-        if custom_config == None:
+        if custom_config is None:
             return
         for plugin in self.plugins:
@@ -626,5 +635,5 @@
                     frame = plugin.get_frame()
                     frame.Show(True)
-                    #break
+                    # break
                 else:
                     frame = plugin.get_frame()
@@ -683,5 +692,5 @@
             try:
                 flag = self.panel_on_focus.get_save_flag()
-                if self._save_appl_menu != None:
+                if self._save_appl_menu is not None:
                     self._save_appl_menu.Enable(flag)
 
@@ -694,7 +703,7 @@
                                 self.panel_on_focus is not None:
                     self.set_panel_on_focus_helper()
-                    #update toolbar
+                    # update toolbar
                     self._update_toolbar_helper()
-                    #update edit menu
+                    # update edit menu
                     self.enable_edit_menu()
             except wx._core.PyDeadObjectError:
@@ -711,5 +720,5 @@
         Send focusing on ID to data explorer
         """
-        if self._data_panel != None:
+        if self._data_panel is not None:
             self._data_panel.set_panel_on_focus(name)
 
@@ -720,5 +729,5 @@
         caption = self.panel_on_focus.window_caption
         self.send_focus_to_datapanel(caption)
-        #update combo
+        # update combo
         if self.panel_on_focus in self.plot_panels.values():
             combo = self._data_panel.cb_plotpanel
@@ -739,6 +748,6 @@
         """
         cpanel = panel
-        if self._toolbar != None and cpanel._bookmark_flag:
-            for item in  self._toolbar.get_bookmark_items():
+        if self._toolbar is not None and cpanel._bookmark_flag:
+            for item in self._toolbar.get_bookmark_items():
                 self._toolbar.remove_bookmark_item(item)
             self._toolbar.add_bookmark_default()
@@ -841,5 +850,6 @@
         field = self.sb.get_msg_position()
         wx.Frame.PushStatusText(self, field=field,
-                                string="FIXME - PushStatusText called without text")
+                                string=
+                                "FIXME - PushStatusText called without text")
 
     def add_perspective(self, plugin):
@@ -866,11 +876,12 @@
         """
         plugins = []
-        #import guiframe local plugins
-        #check if the style contain guiframe.dataloader
+        # import guiframe local plugins
+        # check if the style contain guiframe.dataloader
         style1 = self.__gui_style & GUIFRAME.DATALOADER_ON
         style2 = self.__gui_style & GUIFRAME.PLOTTING_ON
         if style1 == GUIFRAME.DATALOADER_ON:
             try:
-                from sas.sasgui.guiframe.local_perspectives.data_loader import data_loader
+                from sas.sasgui.guiframe.local_perspectives.data_loader \
+                    import data_loader
                 self._data_plugin = data_loader.Plugin()
                 plugins.append(self._data_plugin)
@@ -881,5 +892,6 @@
         if style2 == GUIFRAME.PLOTTING_ON:
             try:
-                from sas.sasgui.guiframe.local_perspectives.plotting import plotting
+                from sas.sasgui.guiframe.local_perspectives.plotting \
+                    import plotting
                 self._plotting_plugin = plotting.Plugin()
                 plugins.append(self._plotting_plugin)
@@ -907,5 +919,5 @@
             else:
                 file_list = []
-            ## the default panel is the panel is the last plugin added
+            # the default panel is the panel is the last plugin added
             for item in file_list:
                 toks = os.path.splitext(os.path.basename(item))
@@ -914,6 +926,6 @@
                     if toks[1] == '.py' or toks[1] == '':
                         name = toks[0]
-                    #check the validity of the module name parsed
-                    #before trying to import it
+                    # check the validity of the module name parsed
+                    # before trying to import it
                     if name is None or name.strip() == '':
                         continue
@@ -941,5 +953,5 @@
                         logging.error(msg)
                     finally:
-                        if not file == None:
+                        if file is not None:
                             file.close()
         except:
@@ -956,5 +968,5 @@
         """
         self._window_width, self._window_height = self.get_client_size()
-        ## Default size
+        # Default size
         if DATAPANEL_WIDTH < 0:
             panel_width = int(self._window_width * 0.25)
@@ -962,5 +974,5 @@
             panel_width = DATAPANEL_WIDTH
         panel_height = int(self._window_height)
-        if self._data_panel is not None  and (p == self._data_panel):
+        if self._data_panel is not None and (p == self._data_panel):
             return panel_width, panel_height
         if hasattr(p, "CENTER_PANE") and p.CENTER_PANE:
@@ -994,5 +1006,6 @@
         if self.welcome_panel_class is not None:
             welcome_panel = MDIFrame(self, None, 'None', (100, 200))
-            self.defaultPanel = self.welcome_panel_class(welcome_panel, -1, style=wx.RAISED_BORDER)
+            self.defaultPanel = self.welcome_panel_class(welcome_panel, -1,
+                                                         style=wx.RAISED_BORDER)
             welcome_panel.set_panel(self.defaultPanel)
             self.defaultPanel.set_frame(welcome_panel)
@@ -1010,5 +1023,5 @@
                 frame.SetPosition((0, mac_pos_y + size_t_bar))
             frame.Show(True)
-        #add data panel
+        # add data panel
         win = MDIFrame(self, None, 'None', (100, 200))
         data_panel = DataPanel(parent=win, id=-1)
@@ -1018,5 +1031,6 @@
         d_panel_width, h = self._get_panels_size(self._data_panel)
         win.SetSize((d_panel_width, h))
-        is_visible = self.__gui_style & GUIFRAME.MANAGER_ON == GUIFRAME.MANAGER_ON
+        is_visible = self.__gui_style & \
+                     GUIFRAME.MANAGER_ON == GUIFRAME.MANAGER_ON
         if IS_WIN:
             win.SetPosition((0, 0))
@@ -1064,5 +1078,5 @@
         Update the data.
         """
-        prev_id, data_state = self._data_manager.update_data( \
+        prev_id, data_state = self._data_manager.update_data(
                               prev_data=prev_data, new_data=new_data)
 
@@ -1115,5 +1129,4 @@
         self._current_perspective.delete_data(data)
 
-
     def get_context_menu(self, plotpanel=None):
         """
@@ -1139,5 +1152,5 @@
         menu_list = []
         item = self._current_perspective
-        if item != None:
+        if item is not None:
             menu_list.extend(item.get_context_menu(plotpanel=plotpanel))
         return menu_list
@@ -1158,5 +1171,4 @@
             self.cpanel_on_focus.SetFocus()
 
-
     def popup_panel(self, p):
         """
@@ -1170,5 +1182,5 @@
         ID = wx.NewId()
         self.panels[str(ID)] = p
-        ## Check and set the size
+        # Check and set the size
         if PLOPANEL_WIDTH < 0:
             p_panel_width = int(self._window_width * 0.45)
@@ -1209,5 +1221,5 @@
         # Register for showing/hiding the panel
         wx.EVT_MENU(self, ID, self.on_view)
-        if p not in self.plot_panels.values() and p.group_id != None:
+        if p not in self.plot_panels.values() and p.group_id is not None:
             self.plot_panels[ID] = p
             if len(self.plot_panels) == 1:
@@ -1215,5 +1227,5 @@
                 self.set_panel_on_focus(None)
             if self._data_panel is not None and \
-                self._plotting_plugin is not None:
+                            self._plotting_plugin is not None:
                 ind = self._data_panel.cb_plotpanel.FindString('None')
                 if ind != wx.NOT_FOUND:
@@ -1258,5 +1270,5 @@
         panel_name = 'No Panel on Focus'
         c_panel = self.cpanel_on_focus
-        if self._toolbar is  None:
+        if self._toolbar is None:
             return
         if c_panel is not None:
@@ -1303,7 +1315,7 @@
         """
         if self._menubar is None or self._current_perspective is None \
-            or self._menubar.GetMenuCount() == 0:
+                or self._menubar.GetMenuCount() == 0:
             return
-        #replace or add a new menu for the current plugin
+        # replace or add a new menu for the current plugin
         pos = self._menubar.FindMenu(str(self._applications_menu_name))
         if pos == -1 and self._applications_menu_pos > 0:
@@ -1325,5 +1337,5 @@
                 for (menu, name) in menu_list:
                     if self._applications_menu_pos == -1:
-                        # Find the Analysis position and insert just after it if possible
+                        # Find the Analysis position and insert just after it
                         analysis_pos = self._menubar.FindMenu("Analysis")
                         if analysis_pos == -1:
@@ -1334,5 +1346,6 @@
                             self._applications_menu_pos = analysis_pos + 1
                     else:
-                        self._menubar.Insert(self._applications_menu_pos, menu, name)
+                        self._menubar.Insert(self._applications_menu_pos,
+                                             menu, name)
                     self._applications_menu_name = name
 
@@ -1362,5 +1375,6 @@
         if config._do_acknowledge:
             wx_id = wx.NewId()
-            self._help_menu.Append(wx_id, '&Acknowledge', 'Acknowledging SasView')
+            self._help_menu.Append(wx_id, '&Acknowledge',
+                                   'Acknowledging SasView')
             wx.EVT_MENU(self, wx_id, self._onAcknowledge)
 
@@ -1379,5 +1393,6 @@
         wx_id = wx.NewId()
         self._help_menu.Append(wx_id, '&Check for update',
-                               'Check for the latest version of %s' % config.__appname__)
+                               'Check for the latest version of %s' %
+                               config.__appname__)
         wx.EVT_MENU(self, wx_id, self._check_update)
         self._menubar.Append(self._help_menu, '&Help')
@@ -1400,5 +1415,6 @@
         wx_id = wx.NewId()
         self._data_panel_menu = self._view_menu.Append(wx_id,
-                                                       '&Show Data Explorer', '')
+                                                       '&Show Data Explorer',
+                                                       '')
         wx.EVT_MENU(self, wx_id, self.show_data_panel)
         if style == GUIFRAME.MANAGER_ON:
@@ -1411,10 +1427,12 @@
         style1 = self.__gui_style & GUIFRAME.TOOLBAR_ON
         if style1 == GUIFRAME.TOOLBAR_ON:
-            self._toolbar_menu = self._view_menu.Append(wx_id, '&Hide Toolbar', '')
+            self._toolbar_menu = self._view_menu.Append(wx_id, '&Hide Toolbar',
+                                                        '')
         else:
-            self._toolbar_menu = self._view_menu.Append(wx_id, '&Show Toolbar', '')
+            self._toolbar_menu = self._view_menu.Append(wx_id, '&Show Toolbar',
+                                                        '')
         wx.EVT_MENU(self, wx_id, self._on_toggle_toolbar)
 
-        if custom_config != None:
+        if custom_config is not None:
             self._view_menu.AppendSeparator()
             wx_id = wx.NewId()
@@ -1427,5 +1445,6 @@
         wx_id = wx.NewId()
         self._view_menu.AppendSeparator()
-        self._view_menu.Append(wx_id, 'Category Manager', 'Edit model categories')
+        self._view_menu.Append(wx_id, 'Category Manager',
+                               'Edit model categories')
         wx.EVT_MENU(self, wx_id, self._on_category_manager)
 
@@ -1440,5 +1459,5 @@
         self.batch_frame.Show(True)
 
-    def  on_category_panel(self, event):
+    def on_category_panel(self, event):
         """
         On cat panel
@@ -1459,5 +1478,5 @@
         """
         from sas.sasgui.guiframe.startup_configuration \
-        import StartupConfiguration as ConfDialog
+            import StartupConfiguration as ConfDialog
 
         dialog = ConfDialog(parent=self, gui=self.__gui_style)
@@ -1466,5 +1485,6 @@
             dialog.write_custom_config()
             # post event for info
-            wx.PostEvent(self, StatusEvent(status="Wrote custom configuration", info='info'))
+            wx.PostEvent(self, StatusEvent(status="Wrote custom configuration",
+                                           info='info'))
         dialog.Destroy()
 
@@ -1485,11 +1505,13 @@
                     id = wx.NewId()
                     if plug.use_data():
-                        self._applications_menu.InsertCheckItem(pos, id, plug.sub_menu, \
-                            "Switch to analysis: %s" % plug.sub_menu)
+                        self._applications_menu.InsertCheckItem(pos, id,
+                                                                plug.sub_menu,
+                                    "Switch to analysis: %s" % plug.sub_menu)
                         plug_data_count = True
                         pos += 1
                     else:
                         plug_no_data_count = True
-                        self._applications_menu.AppendCheckItem(id, plug.sub_menu, \
+                        self._applications_menu.AppendCheckItem(id,
+                                                                plug.sub_menu,
                             "Switch to analysis: %s" % plug.sub_menu)
                     wx.EVT_MENU(self, id, plug.on_perspective)
@@ -1497,14 +1519,14 @@
             if not plug_data_count or not plug_no_data_count:
                 self._applications_menu.RemoveItem(separator)
-            #Windows introduces a "Window" menu item during the layout process
-            #somehow.  We want it to be next to the last item with Help as
-            #last. However Analysis gets stuck after Window in normal ordering
-            #so force it to be next after the Tools menu item.  Should we add
-            #another menu item will need to check if this is still where we 
-            #want Analysis.  This is NOT an issue on the Mac which does not
-            #have the extra Window menu item.
+            # Windows introduces a "Window" menu item during the layout process
+            # somehow.  We want it to be next to the last item with Help as
+            # last. However Analysis gets stuck after Window in normal ordering
+            # so force it to be next after the Tools menu item.  Should we add
+            # another menu item will need to check if this is still where we
+            # want Analysis.  This is NOT an issue on the Mac which does not
+            # have the extra Window menu item.
             #      March 2016 Code Camp  -- PDB 
             Tools_pos = self._menubar.FindMenu("Tools")
-            self._menubar.Insert(Tools_pos+1,self._applications_menu,
+            self._menubar.Insert(Tools_pos+1, self._applications_menu,
                                  '&Analysis')
             self._check_applications_menu()
@@ -1527,5 +1549,7 @@
             wx_id = wx.NewId()
             hint_load_file = "read all analysis states saved previously"
-            self._save_appl_menu = self._file_menu.Append(wx_id, '&Open Project', hint_load_file)
+            self._save_appl_menu = self._file_menu.Append(wx_id,
+                                                          '&Open Project',
+                                                          hint_load_file)
             wx.EVT_MENU(self, wx_id, self._on_open_state_project)
 
@@ -1536,5 +1560,6 @@
             wx_id = wx.NewId()
             self._save_appl_menu = self._file_menu.Append(wx_id,
-                                                          '&Open Analysis', hint_load_file)
+                                                          '&Open Analysis',
+                                                          hint_load_file)
             wx.EVT_MENU(self, wx_id, self._on_open_state_application)
         if OPEN_SAVE_MENU:
@@ -1546,6 +1571,7 @@
         if style1 == GUIFRAME.MULTIPLE_APPLICATIONS:
             wx_id = wx.NewId()
-            self._save_appl_menu = self._file_menu.Append(wx_id, \
-                '&Save Analysis', 'Save state of the current active analysis panel')
+            txt = '&Save Analysis'
+            txt2 = 'Save state of the current active analysis panel'
+            self._save_appl_menu = self._file_menu.Append(wx_id, txt, txt2)
             wx.EVT_MENU(self, wx_id, self._on_save_application)
         if not sys.platform == 'darwin':
@@ -1589,13 +1615,14 @@
 
         self._edit_menu_copyas = wx.Menu()
-        #Sub menu for Copy As...
-        self._edit_menu_copyas.Append(GUIFRAME_ID.COPYEX_ID, 'Copy current tab to Excel',
+        # Sub menu for Copy As...
+        self._edit_menu_copyas.Append(GUIFRAME_ID.COPYEX_ID,
+                                      'Copy current tab to Excel',
                                       'Copy parameter values in tabular format')
         wx.EVT_MENU(self, GUIFRAME_ID.COPYEX_ID, self.on_copy_panel)
 
-        self._edit_menu_copyas.Append(GUIFRAME_ID.COPYLAT_ID, 'Copy current tab to LaTeX',
+        self._edit_menu_copyas.Append(GUIFRAME_ID.COPYLAT_ID,
+                                      'Copy current tab to LaTeX',
                                       'Copy parameter values in tabular format')
         wx.EVT_MENU(self, GUIFRAME_ID.COPYLAT_ID, self.on_copy_panel)
-
 
         self._edit_menu.AppendMenu(GUIFRAME_ID.COPYAS_ID, 'Copy Params as...',
@@ -1620,5 +1647,5 @@
         Return the gui style
         """
-        return  self.__gui_style
+        return self.__gui_style
 
     def _add_menu_data(self):
@@ -1675,5 +1702,5 @@
             return
         frame = self.panels['default'].get_frame()
-        if frame == None:
+        if frame is None:
             return
         # Show default panel
@@ -1708,5 +1735,5 @@
                 self.schedule_full_draw_list.remove(panel)
 
-            #delete uid number not str(uid)
+            # delete uid number not str(uid)
             if ID in self.plot_panels.keys():
                 del self.plot_panels[ID]
@@ -1734,9 +1761,9 @@
             return
 
-        #reading a state file
+        # reading a state file
         for plug in self.plugins:
             reader, ext = plug.get_extensions()
             if reader is not None:
-                #read the state of the single plugin
+                # read the state of the single plugin
                 if extension == ext:
                     reader.read(path)
@@ -1749,5 +1776,6 @@
                         msg += "\n(%s)" % sys.exc_value
                         wx.PostEvent(self, StatusEvent(status=msg,
-                                                       info="error", type="stop"))
+                                                       info="error",
+                                                       type="stop"))
                         return
 
@@ -1788,5 +1816,5 @@
             basename = os.path.basename(path)
             if APPLICATION_STATE_EXTENSION is not None \
-                and basename.endswith(APPLICATION_STATE_EXTENSION):
+                    and basename.endswith(APPLICATION_STATE_EXTENSION):
                 if is_project:
                     for ID in self.plot_panels.keys():
@@ -1858,5 +1886,5 @@
         """
         path = None
-        if self._default_save_location == None:
+        if self._default_save_location is None:
             self._default_save_location = os.getcwd()
         wx.PostEvent(self, StatusEvent(status="Loading Analysis file..."))
@@ -1892,5 +1920,5 @@
                     break
             # Found the extension
-            if ind != None:
+            if ind is not None:
                 plug_wlist.remove(ind)
                 plug_wlist.insert(0, ind)
@@ -1910,20 +1938,22 @@
         """
         path = None
-        if self._default_save_location == None:
+        if self._default_save_location is None:
             self._default_save_location = os.getcwd()
         msg = "This operation will set remove all data, plots and analyses from"
         msg += " SasView before loading the project. Do you wish to continue?"
-        self._data_panel.selection_cbox.SetValue('Select all Data')
-        self._data_panel._on_selection_type(None)
-        for _, theory_dict in self._data_panel.list_cb_theory.iteritems():
-            for  key, value in theory_dict.iteritems():
-                item, _, _ = value
-                item.Check(True)
-        if not self._data_panel.on_remove(None, msg):
+        msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK | wx.CANCEL)
+        if msg_box.ShowModal() == wx.ID_OK:
+            self._data_panel.selection_cbox.SetValue('Select all Data')
+            self._data_panel._on_selection_type(None)
+            for _, theory_dict in self._data_panel.list_cb_theory.iteritems():
+                for key, value in theory_dict.iteritems():
+                    item, _, _ = value
+                    item.Check(True)
+            self._data_panel.on_remove(None, False)
+
             wx.PostEvent(self, StatusEvent(status="Loading Project file..."))
-            dlg = wx.FileDialog(self,
-                            "Choose a file",
-                            self._default_save_location, "",
-                            APPLICATION_WLIST)
+            dlg = wx.FileDialog(self, "Choose a file",
+                                self._default_save_location, "",
+                                APPLICATION_WLIST)
             if dlg.ShowModal() == wx.ID_OK:
                 path = dlg.GetPath()
@@ -1969,5 +1999,5 @@
         save the state of the SasView as *.svs
         """
-        if self._current_perspective is  None:
+        if self._current_perspective is None:
             return
         wx.PostEvent(self, StatusEvent(status="Saving Project file..."))
@@ -1997,5 +2027,5 @@
             extens = APPLICATION_STATE_EXTENSION
             fName = os.path.splitext(path)[0] + extens
-            if doc != None:
+            if doc is not None:
                 fd = open(fName, 'w')
                 fd.write(doc.toprettyxml())
@@ -2029,5 +2059,5 @@
                     if data is not None:
                         new_doc = reader.write_toXML(data, state)
-                        if doc != None and hasattr(doc, "firstChild"):
+                        if doc is not None and hasattr(doc, "firstChild"):
                             child = new_doc.firstChild.firstChild
                             doc.firstChild.appendChild(child)
@@ -2040,5 +2070,5 @@
                 if data is not None:
                     new_doc = reader.write_toXML(data, state)
-                    if doc != None and hasattr(doc, "firstChild"):
+                    if doc is not None and hasattr(doc, "firstChild"):
                         child = new_doc.firstChild.firstChild
                         doc.firstChild.appendChild(child)
@@ -2095,5 +2125,5 @@
             except:
                 logging.info("Failed to connect to www.sasview.org")
-        self._process_version(version_info, standalone=event == None)
+        self._process_version(version_info, standalone=event is None)
 
     def _process_version(self, version_info, standalone=True):
@@ -2184,9 +2214,11 @@
                     try:
                         # Try an alternate method
-                        logging.error("Could not open the tutorial pdf, trying xhtml2pdf")
+                        logging.error(
+                            "Could not open the tutorial pdf, trying xhtml2pdf")
                         from xhtml2pdf import pisa
                         pisa.startViewer(path)
                     except:
-                        logging.error("Could not open the tutorial pdf with xhtml2pdf")
+                        logging.error(
+                            "Could not open the tutorial pdf with xhtml2pdf")
                         msg = "This feature requires 'PDF Viewer'\n"
                         wx.MessageBox(msg, 'Error')
@@ -2198,10 +2230,12 @@
                     try:
                         # Try an alternate method
-                        logging.error("Could not open the tutorial pdf, trying xhtml2pdf")
+                        logging.error(
+                            "Could not open the tutorial pdf, trying xhtml2pdf")
                         from xhtml2pdf import pisa
                         pisa.startViewer(path)
                     except:
-                        logging.error("Could not open the tutorial pdf with xhtml2pdf")
-                        msg = "This feature requires the 'Preview' application\n"
+                        logging.error(
+                            "Could not open the tutorial pdf with xhtml2pdf")
+                        msg = "This feature requires the Preview application\n"
                         wx.MessageBox(msg, 'Error')
 
@@ -2218,5 +2252,6 @@
         from documentation_window import DocumentationWindow
         _TreeLocation = "user/user.html"
-        DocumentationWindow(self, -1, _TreeLocation, "", "SasView Documentation")
+        DocumentationWindow(self, -1, _TreeLocation, "",
+                            "SasView Documentation")
 
     def set_manager(self, manager):
@@ -2252,5 +2287,5 @@
                 if self.panels[item].ALWAYS_ON:
                     continue
-            if self.panels[item] == None:
+            if self.panels[item] is None:
                 continue
             if self.panels[item].window_name in panels:
@@ -2261,8 +2296,9 @@
                 # always show the data panel if enable
                 style = self.__gui_style & GUIFRAME.MANAGER_ON
-                if (style == GUIFRAME.MANAGER_ON) and self.panels[item] == self._data_panel:
+                if (style == GUIFRAME.MANAGER_ON) \
+                        and self.panels[item] == self._data_panel:
                     if 'data_panel' in self.panels.keys():
                         frame = self.panels['data_panel'].get_frame()
-                        if frame == None:
+                        if frame is None:
                             continue
                         flag = frame.IsShown()
@@ -2270,5 +2306,5 @@
                 else:
                     frame = self.panels[item].get_frame()
-                    if frame == None:
+                    if frame is None:
                         continue
 
@@ -2280,5 +2316,5 @@
         show the data panel
         """
-        if self._data_panel_menu == None:
+        if self._data_panel_menu is None:
             return
         label = self._data_panel_menu.GetText()
@@ -2310,5 +2346,5 @@
         :param data_list: dictionary of data's ID and value Data
         """
-        #Store data into manager
+        # Store data into manager
         self.add_data_helper(data_list)
         # set data in the data panel
@@ -2316,14 +2352,14 @@
             data_state = self._data_manager.get_data_state(data_list.keys())
             self._data_panel.load_data_list(data_state)
-        #if the data panel is shown wait for the user to press a button
-        #to send data to the current perspective. if the panel is not
-        #show  automatically send the data to the current perspective
+        # if the data panel is shown wait for the user to press a button
+        # to send data to the current perspective. if the panel is not
+        # show  automatically send the data to the current perspective
         style = self.__gui_style & GUIFRAME.MANAGER_ON
         if style == GUIFRAME.MANAGER_ON:
-            #wait for button press from the data panel to set_data
+            # wait for button press from the data panel to set_data
             if self._data_panel is not None:
                 self._data_panel.frame.Show(True)
         else:
-            #automatically send that to the current perspective
+            # automatically send that to the current perspective
             self.set_data(data_id=data_list.keys())
 
@@ -2386,8 +2422,8 @@
                                                        info='warning'))
             else:
-                #if not append then new plot
+                # if not append then new plot
                 from sas.sasgui.guiframe.dataFitting import Data2D
                 if issubclass(Data2D, new_plot.__class__):
-                    #for 2 D always plot in a separated new plot
+                    # for 2 D always plot in a separated new plot
                     new_plot.group_id = wx.NewId()
                 else:
@@ -2420,5 +2456,5 @@
                                                 group_id=group_id,
                                                 action='remove'))
-                #remove res plot: Todo: improve
+                # remove res plot: Todo: improve
                 wx.CallAfter(self._remove_res_plot, new_plot.id)
         self._data_manager.delete_data(data_id=data_id,
@@ -2462,5 +2498,5 @@
             mypath = os.path.basename(path)
 
-            #Instantiate a loader
+            # Instantiate a loader
             loader = Loader()
             ext_format = ".txt"
@@ -2482,5 +2518,4 @@
         dlg.Destroy()
 
-
     def _onsaveTXT(self, data, path):
         """
@@ -2489,8 +2524,8 @@
         .. todo:: Refactor and remove this method. See 'TODO' in _onSave.
         """
-        if not path == None:
+        if path is not None:
             out = open(path, 'w')
             has_errors = True
-            if data.dy == None or data.dy == []:
+            if data.dy is None or data.dy == []:
                 has_errors = False
             # Sanity check
@@ -2502,5 +2537,5 @@
                     has_errors = False
             if has_errors:
-                if data.dx != None and data.dx != []:
+                if data.dx is not None and data.dx != []:
                     out.write("<X>   <Y>   <dY>   <dX>\n")
                 else:
@@ -2511,6 +2546,6 @@
             for i in range(len(data.x)):
                 if has_errors:
-                    if data.dx != None and data.dx != []:
-                        if  data.dx[i] != None:
+                    if data.dx is not None and data.dx != []:
+                        if data.dx[i] is not None:
                             out.write("%g  %g  %g  %g\n" % (data.x[i],
                                                             data.y[i],
@@ -2543,27 +2578,27 @@
                                            info="error"))
             raise ValueError, msg
-        ## text = str(data)
+        # text = str(data)
         text = data.__str__()
         text += 'Data Min Max:\n'
         text += 'X_min = %s:  X_max = %s\n' % (xmin, max(data.x))
         text += 'Y_min = %s:  Y_max = %s\n' % (ymin, max(data.y))
-        if data.dy != None:
+        if data.dy is not None:
             text += 'dY_min = %s:  dY_max = %s\n' % (min(data.dy), max(data.dy))
         text += '\nData Points:\n'
         x_st = "X"
         for index in range(len(data.x)):
-            if data.dy != None and len(data.dy) > index:
+            if data.dy is not None and len(data.dy) > index:
                 dy_val = data.dy[index]
             else:
                 dy_val = 0.0
-            if data.dx != None and len(data.dx) > index:
+            if data.dx is not None and len(data.dx) > index:
                 dx_val = data.dx[index]
             else:
                 dx_val = 0.0
-            if data.dxl != None and len(data.dxl) > index:
+            if data.dxl is not None and len(data.dxl) > index:
                 if index == 0:
                     x_st = "Xl"
                 dx_val = data.dxl[index]
-            elif data.dxw != None and len(data.dxw) > index:
+            elif data.dxw is not None and len(data.dxw) > index:
                 if index == 0:
                     x_st = "Xw"
@@ -2605,5 +2640,5 @@
             mypath = os.path.basename(path)
 
-            #Instantiate a loader
+            # Instantiate a loader
             loader = Loader()
 
@@ -2642,9 +2677,9 @@
             y_val = data.qy_data[index]
             i_val = data.data[index]
-            if data.err_data != None:
+            if data.err_data is not None:
                 di_val = data.err_data[index]
-            if data.dqx_data != None:
+            if data.dqx_data is not None:
                 dx_val = data.dqx_data[index]
-            if data.dqy_data != None:
+            if data.dqy_data is not None:
                 dy_val = data.dqy_data[index]
 
@@ -2681,5 +2716,5 @@
                     for name in self._current_perspective.get_perspective():
                         frame = panel.get_frame()
-                        if frame != None:
+                        if frame is not None:
                             if name == panel.window_name:
                                 panel.on_set_focus(event=None)
@@ -2691,5 +2726,5 @@
                 self._data_panel.set_active_perspective(name)
                 self._check_applications_menu()
-            #Set the SasView title
+            # Set the SasView title
             self._set_title_name(name)
 
@@ -2723,8 +2758,10 @@
         """
 
-        if self.panel_on_focus not in self._plotting_plugin.plot_panels.values():
+        if self.panel_on_focus \
+                not in self._plotting_plugin.plot_panels.values():
             return
+        check = "Theory1D"
         is_theory = len(self.panel_on_focus.plots) <= 1 and \
-            self.panel_on_focus.plots.values()[0].__class__.__name__ == "Theory1D"
+            self.panel_on_focus.plots.values()[0].__class__.__name__ == check
 
         is_data2d = hasattr(new_plot, 'data')
@@ -2734,15 +2771,16 @@
         has_meta_data = hasattr(new_plot, 'meta_data')
 
-        #disable_add_data if the data is being recovered from  a saved state file.
+        # disable_add_data if the data is being recovered from  a saved state
         is_state_data = False
         if has_meta_data:
             if 'invstate' in new_plot.meta_data:
                 is_state_data = True
-            if  'prstate' in new_plot.meta_data:
+            if 'prstate' in new_plot.meta_data:
                 is_state_data = True
-            if  'fitstate' in new_plot.meta_data:
+            if 'fitstate' in new_plot.meta_data:
                 is_state_data = True
 
-        return is_data1d and not is_data2d and not is_theory and not is_state_data
+        return is_data1d and not is_data2d and not is_theory \
+               and not is_state_data
 
     def check_multimode(self, perspective=None):
@@ -2750,5 +2788,5 @@
         Check the perspective have batch mode capablitity
         """
-        if perspective == None or self._data_panel == None:
+        if perspective is None or self._data_panel is None:
             return
         flag = perspective.get_batch_capable()
@@ -2777,5 +2815,5 @@
             self._edit_menu.Enable(GUIFRAME_ID.PASTE_ID, flag)
 
-            #Copy menu
+            # Copy menu
             flag = self.cpanel_on_focus.get_copy_flag()
             self._edit_menu_copyas.Enable(GUIFRAME_ID.COPYEX_ID, flag)
@@ -2908,6 +2946,6 @@
             if data_panel.cb_plotpanel is not None:
                 # Check if any panel has the same caption
-                has_newstring = data_panel.cb_plotpanel.FindString\
-                                                            (str(new_caption))
+                has_newstring = data_panel.cb_plotpanel.FindString(
+                    str(new_caption))
                 caption = new_caption
                 if has_newstring != wx.NOT_FOUND:
@@ -3026,5 +3064,5 @@
         drag
         """
-        #Not implemeted
+        # Not implemeted
 
     def enable_reset(self):
@@ -3039,5 +3077,5 @@
         """
         size_y = 0
-        if self.GetToolBar() != None and self.GetToolBar().IsShown():
+        if self.GetToolBar() is not None and self.GetToolBar().IsShown():
             if not IS_LINUX:
                 _, size_y = self.GetToolBar().GetSizeTuple()
@@ -3054,5 +3092,5 @@
         # append this panel in the schedule list if not in yet
         if func == 'append':
-            if not panel in self.schedule_full_draw_list:
+            if panel not in self.schedule_full_draw_list:
                 self.schedule_full_draw_list.append(panel)
         # remove this panel from schedule list
@@ -3074,5 +3112,5 @@
 
         count = len(self.schedule_full_draw_list)
-        #if not self.schedule:
+        # if not self.schedule:
         if count < 1:
             self.set_schedule(False)
@@ -3089,5 +3127,6 @@
                 if ind == count:
                     return
-        #Simple redraw only for a panel shown
+        # Simple redraw only for a panel shown
+
         def f_draw(panel):
             """
@@ -3102,5 +3141,5 @@
                     # draw if possible
                     panel.set_resizing(False)
-                    #panel.Show(True)
+                    # panel.Show(True)
                     panel.draw_plot()
                 # Check if the panel is not shown
@@ -3137,7 +3176,7 @@
         Set focus on a plot panel
         """
-        if panel == None:
+        if panel is None:
             return
-        #self.set_plot_unfocus()
+        # self.set_plot_unfocus()
         panel.on_set_focus(None)
         # set focusing panel
@@ -3172,5 +3211,5 @@
         try:
             # check if it is time to redraw
-            if self.GetCapture() == None:
+            if self.GetCapture() is None:
                 # Draw plot, changes resizing too
                 self.full_draw()
@@ -3180,5 +3219,4 @@
         # restart idle
         self._redraw_idle(*args, **kwargs)
-
 
     def _redraw_idle(self, *args, **kwargs):
@@ -3195,14 +3233,14 @@
     the GUI manager
     """
-    ## Internal nickname for the window, used by the AUI manager
+    # Internal nickname for the window, used by the AUI manager
     window_name = "default"
-    ## Name to appear on the window title bar
+    # Name to appear on the window title bar
     window_caption = "Welcome panel"
-    ## Flag to tell the AUI manager to put this panel in the center pane
+    # Flag to tell the AUI manager to put this panel in the center pane
     CENTER_PANE = True
+
     def __init__(self, parent, *args, **kwds):
         wx.Panel.__init__(self, parent, *args, **kwds)
         PanelBase.__init__(self, parent)
-
 
 
@@ -3236,6 +3274,7 @@
         try:
             if os.path.isfile(SPLASH_SCREEN_PATH):
-                self.s_screen = self.display_splash_screen(parent=self.frame,
-                                                           path=SPLASH_SCREEN_PATH)
+                self.s_screen = \
+                    self.display_splash_screen(parent=self.frame,
+                                               path=SPLASH_SCREEN_PATH)
             else:
                 self.frame.Show()
@@ -3300,5 +3339,5 @@
                             os.remove(file_path)
                 except:
-                    logging.error("gui_manager.clean_plugin_models:\n  %s" \
+                    logging.error("gui_manager.clean_plugin_models:\n  %s"
                                   % sys.exc_value)
 
@@ -3314,5 +3353,5 @@
         Build the GUI
         """
-        #try to load file at the start
+        # try to load file at the start
         self.open_file()
         self.frame.build_gui()
@@ -3390,5 +3429,4 @@
         # Return the suggested position and size for the application frame.
         return (posX, posY), (customWidth, customHeight), is_maximized
-
 
     def display_splash_screen(self, parent,
@@ -3427,5 +3465,4 @@
         return s_screen
 
-
     def on_close_splash_screen(self, event):
         """
@@ -3447,10 +3484,11 @@
         """
         # Initialize the Frame object
-        CHILD_FRAME.__init__(self, parent=parent, id=wx.ID_ANY, title=title, size=size)
+        CHILD_FRAME.__init__(self, parent=parent, id=wx.ID_ANY,
+                             title=title, size=size)
         self.parent = parent
         self.name = "Untitled"
         self.batch_on = self.parent.batch_on
         self.panel = panel
-        if panel != None:
+        if panel is not None:
             self.set_panel(panel)
         self.Show(False)
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
Index: src/sas/sasgui/perspectives/fitting/fitpage.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/fitpage.py	(revision 3bec50ae2f0e34d160b7c5524ce22736baa10388)
+++ src/sas/sasgui/perspectives/fitting/fitpage.py	(revision c8e19964f2dda929ccae8237e7b140a906cdf134)
@@ -14,11 +14,15 @@
 from sasmodels.weights import MODELS as POLYDISPERSITY_MODELS
 
-from sas.sasgui.guiframe.events import StatusEvent
-from sas.sasgui.guiframe.events import NewPlotEvent
-from sas.sasgui.guiframe.events import PlotQrangeEvent
+from sas.sasgui.guiframe.events import StatusEvent, NewPlotEvent, \
+    PlotQrangeEvent
 from sas.sasgui.guiframe.dataFitting import check_data_validity
-from sas.sasgui.guiframe.utils import format_number
-from sas.sasgui.guiframe.utils import check_float
+from sas.sasgui.guiframe.utils import format_number, check_float
 from sas.sasgui.guiframe.documentation_window import DocumentationWindow
+
+from sas.sasgui.perspectives.fitting.basepage import BasicPage as BasicPage
+from sas.sasgui.perspectives.fitting.basepage import PageInfoEvent as \
+    PageInfoEvent
+from sas.sascalc.data_util.qsmearing import smear_selection
+from .basepage import ModelTextCtrl
 
 (Chi2UpdateEvent, EVT_CHI2_UPDATE) = wx.lib.newevent.NewEvent()
@@ -28,9 +32,4 @@
 SMEAR_SIZE_H = 0.00
 
-from sas.sasgui.perspectives.fitting.basepage import BasicPage as BasicPage
-from sas.sasgui.perspectives.fitting.basepage import PageInfoEvent as PageInfoEvent
-from sas.sascalc.data_util.qsmearing import smear_selection
-from .basepage import ModelTextCtrl
-
 
 class FitPage(BasicPage):
@@ -49,5 +48,5 @@
         BasicPage.__init__(self, parent, color=color)
 
-        ## draw sizer
+        # draw sizer
         self._fill_data_sizer()
         self.is_2D = None
@@ -72,5 +71,5 @@
         self.enable_fit_button()
         self.fill_data_combobox(data_list=self.data_list)
-        #create a default data for an empty panel
+        # create a default data for an empty panel
         self.create_default_data()
         self._manager.frame.Bind(wx.EVT_SET_FOCUS, self.on_set_focus)
@@ -105,5 +104,5 @@
         self.data_box_description.SetForegroundColour(dname_color)
         boxsizer1 = wx.StaticBoxSizer(self.data_box_description, wx.VERTICAL)
-        #----------------------------------------------------------
+        # ----------------------------------------------------------
         sizer_data = wx.BoxSizer(wx.HORIZONTAL)
         self.dataSource = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY)
@@ -134,5 +133,5 @@
         self.enable_datasource()
         if len(data_list) > 0:
-            #find the maximum range covering all data
+            # find the maximum range covering all data
             qmin, qmax, npts = self.compute_data_set_range(data_list)
             self.qmin_data_set = qmin
@@ -185,5 +184,4 @@
 
         :return: True or False
-
         """
         if self.data.__class__.__name__ == "Data2D" or \
@@ -199,13 +197,13 @@
         buttons, xi^2, number of points etc.
         """
-        is_2Ddata = False
+        is_2d_data = False
 
         # Check if data is 2D
         if self.data.__class__.__name__ == "Data2D" or \
                         self.enable2D:
-            is_2Ddata = True
+            is_2d_data = True
 
         title = "Fitting"
-        #smear messages & titles
+        # smear messages & titles
         smear_message_none = "No smearing is selected..."
         smear_message_dqdata = "The dQ data is being used for smearing..."
@@ -225,5 +223,5 @@
         self._get_smear_info()
 
-        #Sizers
+        # Sizers
         box_description_range = wx.StaticBox(self, wx.ID_ANY, str(title))
         box_description_range.SetForegroundColour(wx.BLUE)
@@ -244,5 +242,5 @@
         sizer_weighting = wx.BoxSizer(wx.HORIZONTAL)
         weighting_box.SetMinSize((_DATA_BOX_WIDTH, 40))
-        #Filling the sizer containing weighting info.
+        # Filling the sizer containing weighting info.
         self.dI_noweight = wx.RadioButton(self, wx.ID_ANY,
                                           'No Weighting', style=wx.RB_GROUP)
@@ -286,5 +284,5 @@
                         self._on_select_accuracy)
 
-        #Fit button
+        # Fit button
         self.btFit = wx.Button(self, self._ids.next(), 'Fit')
         self.default_bt_colour = self.btFit.GetDefaultAttributes()
@@ -292,18 +290,18 @@
         self.btFit.SetToolTipString("Start fitting.")
 
-        #General Help button
+        # General Help button
         self.btFitHelp = wx.Button(self, wx.ID_ANY, 'Help')
         self.btFitHelp.SetToolTipString("General fitting help.")
         self.btFitHelp.Bind(wx.EVT_BUTTON, self._onFitHelp)
         
-        #Resolution Smearing Help button (for now use same technique as
-        #used for dI help to get tiniest possible button that works
-        #both on MAC and PC.  Should completely rewrite the fitting sizer 
-        #in future.  This is minimum to get out release 3.1
+        # Resolution Smearing Help button (for now use same technique as
+        # used for dI help to get tiniest possible button that works
+        # both on MAC and PC.  Should completely rewrite the fitting sizer
+        # in future.  This is minimum to get out release 3.1
         #        comment June 14, 2015     --- PDB
         if sys.platform.count("win32") > 0:
-            size_q = (20, 15)  #on PC
+            size_q = (20, 15)  # on PC
         else:
-            size_q = (30, 20)  #on MAC
+            size_q = (30, 20)  # on MAC
         self.btSmearHelp = wx.Button(self, wx.ID_ANY, '?',
                                      style=wx.BU_EXACTFIT, size=size_q)
@@ -311,5 +309,5 @@
         self.btSmearHelp.Bind(wx.EVT_BUTTON, self._onSmearHelp)
         
-        #textcntrl for custom resolution
+        # textcntrl for custom resolution
         self.smear_pinhole_max = ModelTextCtrl(self, wx.ID_ANY,
                             size=(_BOX_WIDTH - 25, 20),
@@ -329,5 +327,5 @@
                             text_enter_callback=self.onSlitSmear)
 
-        ## smear
+        # smear
         self.smear_data_left = BGTextCtrl(self, wx.ID_ANY,
                                           size=(_BOX_WIDTH - 25, 20), style=0)
@@ -337,5 +335,5 @@
         self.smear_data_right.SetValue(str(self.dq_r))
 
-        #set default values for smear
+        # set default values for smear
         self.smear_pinhole_max.SetValue(str(self.dx_max))
         self.smear_pinhole_min.SetValue(str(self.dx_min))
@@ -343,17 +341,17 @@
         self.smear_slit_width.SetValue(str(self.dxw))
 
-        #Filling the sizer containing instruments smearing info.
+        # Filling the sizer containing instruments smearing info.
         self.disable_smearer = wx.RadioButton(self, wx.ID_ANY,
                                               'None', style=wx.RB_GROUP)
         self.enable_smearer = wx.RadioButton(self, wx.ID_ANY, 'Use dQ Data')
-        #self.enable_smearer.SetToolTipString(
-        #"Click to use the loaded dQ data for smearing.")
+        # self.enable_smearer.SetToolTipString(
+        # "Click to use the loaded dQ data for smearing.")
         self.pinhole_smearer = wx.RadioButton(self, wx.ID_ANY,
                                               'Custom Pinhole Smear')
-        #self.pinhole_smearer.SetToolTipString
-        #("Click to input custom resolution for pinhole smearing.")
+        # self.pinhole_smearer.SetToolTipString
+        # ("Click to input custom resolution for pinhole smearing.")
         self.slit_smearer = wx.RadioButton(self, wx.ID_ANY, 'Custom Slit Smear')
-        #self.slit_smearer.SetToolTipString
-        #("Click to input custom resolution for slit smearing.")
+        # self.slit_smearer.SetToolTipString
+        # ("Click to input custom resolution for slit smearing.")
         self.Bind(wx.EVT_RADIOBUTTON, self.onSmear,
                   id=self.disable_smearer.GetId())
@@ -378,11 +376,11 @@
         self.Npts_fit = BGTextCtrl(self, wx.ID_ANY, "-", size=(75, 20), style=0)
         self.Npts_fit.SetToolTipString(
-                            " Npts : number of points selected for fitting")
+            " Npts : number of points selected for fitting")
         self.Npts_total = ModelTextCtrl(self, wx.ID_ANY, size=(_BOX_WIDTH, 20),
-                            style=wx.TE_PROCESS_ENTER,
-                            text_enter_callback=self._onQrangeEnter)
+                                        style=wx.TE_PROCESS_ENTER,
+                                        text_enter_callback=self._onQrangeEnter)
         self.Npts_total.SetValue(format_number(self.npts_x))
-        self.Npts_total.SetToolTipString(\
-                                " Total Npts : total number of data points")
+        self.Npts_total.SetToolTipString(
+            " Total Npts : total number of data points")
 
         # Update and Draw button
@@ -429,5 +427,5 @@
         self.smear_description_2d_y = wx.StaticText(self, wx.ID_ANY,
                             smear_message_2d_y_title, style=wx.ALIGN_LEFT)
-        self.smear_description_2d_y.SetToolTipString(\
+        self.smear_description_2d_y.SetToolTipString(
                                     " dQs(perpendicular) in q_phi direction.")
         self.smear_description_pin_min = wx.StaticText(self, wx.ID_ANY,
@@ -440,41 +438,37 @@
                         smear_message_slit_width_title, style=wx.ALIGN_LEFT)
 
-        #arrange sizers
+        # arrange sizers
         self.sizer_set_smearer.Add(sizer_smearer)
         self.sizer_set_smearer.Add((10, 10))
         self.sizer_set_smearer.Add(self.smear_description_none,
-                                    0, wx.CENTER, 10)
+                                   0, wx.CENTER, 10)
         self.sizer_set_smearer.Add(self.smear_description_dqdata,
-                                    0, wx.CENTER, 10)
+                                   0, wx.CENTER, 10)
         self.sizer_set_smearer.Add(self.smear_description_2d,
-                                    0, wx.CENTER, 10)
+                                   0, wx.CENTER, 10)
         self.sizer_new_smear.Add(self.smear_description_type,
-                                  0, wx.CENTER, 10)
+                                 0, wx.CENTER, 10)
         self.sizer_new_smear.Add(self.smear_description_accuracy_type,
-                                  0, wx.CENTER, 10)
+                                 0, wx.CENTER, 10)
         self.sizer_new_smear.Add(self.smear_accuracy)
         self.sizer_new_smear.Add(self.smear_description_smear_type,
-                                  0, wx.CENTER, 10)
+                                 0, wx.CENTER, 10)
         self.sizer_new_smear.Add((15, -1))
-        self.sizer_new_smear.Add(self.smear_description_2d_x,
-                                  0, wx.CENTER, 10)
+        self.sizer_new_smear.Add(self.smear_description_2d_x, 0, wx.CENTER, 10)
         self.sizer_new_smear.Add(self.smear_description_pin_min,
-                                  0, wx.CENTER, 10)
+                                 0, wx.CENTER, 10)
         self.sizer_new_smear.Add(self.smear_description_slit_height,
-                                  0, wx.CENTER, 10)
-
-        self.sizer_new_smear.Add(self.smear_pinhole_min,
-                                  0, wx.CENTER, 10)
-        self.sizer_new_smear.Add(self.smear_slit_height,
-                                  0, wx.CENTER, 10)
-        self.sizer_new_smear.Add(self.smear_data_left,
-                                  0, wx.CENTER, 10)
+                                 0, wx.CENTER, 10)
+
+        self.sizer_new_smear.Add(self.smear_pinhole_min, 0, wx.CENTER, 10)
+        self.sizer_new_smear.Add(self.smear_slit_height, 0, wx.CENTER, 10)
+        self.sizer_new_smear.Add(self.smear_data_left, 0, wx.CENTER, 10)
         self.sizer_new_smear.Add((20, -1))
         self.sizer_new_smear.Add(self.smear_description_2d_y,
-                                  0, wx.CENTER, 10)
+                                 0, wx.CENTER, 10)
         self.sizer_new_smear.Add(self.smear_description_pin_max,
-                                  0, wx.CENTER, 10)
+                                 0, wx.CENTER, 10)
         self.sizer_new_smear.Add(self.smear_description_slit_width,
-                                  0, wx.CENTER, 10)
+                                 0, wx.CENTER, 10)
 
         self.sizer_new_smear.Add(self.smear_pinhole_max, 0, wx.CENTER, 10)
@@ -501,6 +495,6 @@
 
         # Show only the relevant smear messages, etc
-        if self.current_smearer == None:
-            if not is_2Ddata:
+        if self.current_smearer is None:
+            if not is_2d_data:
                 self.smear_description_none.Show(True)
                 self.enable_smearer.Disable()
@@ -508,5 +502,5 @@
                 self.smear_description_none.Show(True)
                 self.slit_smearer.Disable()
-            if self.data == None:
+            if self.data is None:
                 self.slit_smearer.Disable()
                 self.pinhole_smearer.Disable()
@@ -515,10 +509,10 @@
             self._show_smear_sizer()
         boxsizer_range.Add(self.sizer_set_masking)
-        #2D data? default
-        is_2Ddata = False
-
-        #check if it is 2D data
+        # 2D data? default
+        is_2d_data = False
+
+        # check if it is 2D data
         if self.data.__class__.__name__ == "Data2D" or self.enable2D:
-            is_2Ddata = True
+            is_2d_data = True
 
         self.sizer5.Clear(True)
@@ -568,5 +562,5 @@
         sizer.Add(wx.StaticText(self, wx.ID_ANY, ' Max[1/A]'))
         sizer.Add(self.EditMask_title)
-        sizer.Add((-1,5))
+        sizer.Add((-1, 5))
 
         sizer.Add(self.reset_qrange)
@@ -574,7 +568,7 @@
         sizer.Add(self.qmax)
         sizer.Add(self.btEditMask)
-        sizer.Add((-1,5))
-
-        sizer.AddMany(5*[(-1,5)])
+        sizer.Add((-1, 5))
+
+        sizer.AddMany(5*[(-1, 5)])
 
         sizer.Add(box_description_1, 0, 0)
@@ -582,5 +576,5 @@
         sizer.Add(self.points_sizer, 0, 0)
         sizer.Add(self.draw_button, 0, 0)
-        sizer.Add((-1,5))
+        sizer.Add((-1, 5))
         
         sizer.Add(self.tcChi, 0, 0)
@@ -592,5 +586,5 @@
         boxsizer_range.Add(sizer_chi2)
         boxsizer_range.Add(sizer)
-        if is_2Ddata:
+        if is_2d_data:
             self.btEditMask.Enable()
             self.EditMask_title.Enable()
@@ -598,10 +592,9 @@
             self.btEditMask.Disable()
             self.EditMask_title.Disable()
-        ## save state
+        # save state
         self.save_current_state()
         self.sizer5.Add(boxsizer_range, 0, wx.EXPAND | wx.ALL, 10)
         self.sizer5.Layout()
 
-
     def _set_sizer_dispersion(self):
         """
@@ -613,14 +606,14 @@
 
         self.sizer4_4.Clear(True)
-        if self.model == None:
-            ##no model is selected
+        if self.model is None:
+            # no model is selected
             return
         if not self.enable_disp.GetValue():
-            ## the user didn't select dispersity display
+            # the user didn't select dispersity display
             return
 
         self._reset_dispersity()
 
-        ## fill a sizer with the combobox to select dispersion type
+        # fill a sizer with the combobox to select dispersion type
         model_disp = wx.StaticText(self, wx.ID_ANY, 'Function')
         CHECK_STATE = False
@@ -645,10 +638,10 @@
             err_text = ''
         self.text_disp_1 = wx.StaticText(self, wx.ID_ANY, err_text)
-        self.sizer4_4.Add(self.text_disp_1, (iy, ix), (1, 1), \
+        self.sizer4_4.Add(self.text_disp_1, (iy, ix), (1, 1),
                           wx.EXPAND | wx.ADJUST_MINSIZE, 0)
 
         ix += 1
         self.text_disp_min = wx.StaticText(self, wx.ID_ANY, 'Min')
-        self.sizer4_4.Add(self.text_disp_min, (iy, ix), (1, 1), \
+        self.sizer4_4.Add(self.text_disp_min, (iy, ix), (1, 1),
                             wx.EXPAND | wx.ADJUST_MINSIZE, 0)
 
@@ -683,6 +676,6 @@
                 if item in self.model.magnetic_params:
                     continue
-            if not item in self.model.orientation_params:
-                if not item in self.disp_cb_dict:
+            if item not in self.model.orientation_params:
+                if item not in self.disp_cb_dict:
                     self.disp_cb_dict[item] = None
                 name0 = "Distribution of " + item
@@ -690,5 +683,5 @@
                 name2 = item + ".npts"
                 name3 = item + ".nsigmas"
-                if not name1 in self.model.details:
+                if name1 not in self.model.details:
                     self.model.details[name1] = ["", None, None]
 
@@ -716,5 +709,5 @@
                         ctl1.SetValue(str(format_number(value, True)))
                         self.sizer4_4.Add(ctl1, (iy, ix), (1, 1), wx.EXPAND)
-                        ## text to show error sign
+                        # text to show error sign
                         ix = 2
                         text2 = wx.StaticText(self, wx.ID_ANY, '+/-')
@@ -776,5 +769,5 @@
                         Tct2.SetValue(str(format_number(value)))
                         self.sizer4_4.Add(Tct2, (iy, ix), (1, 1),
-                                           wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+                                          wx.EXPAND | wx.ADJUST_MINSIZE, 0)
                         self.fixed_param.append([None, name3, Tct2,
                                                  None, None, None,
@@ -802,6 +795,6 @@
                 if item in self.model.magnetic_params:
                     continue
-            if  item in self.model.orientation_params:
-                if not item in self.disp_cb_dict:
+            if item in self.model.orientation_params:
+                if item not in self.disp_cb_dict:
                     self.disp_cb_dict[item] = None
                 name0 = "Distribution of " + item
@@ -810,5 +803,5 @@
                 name3 = item + ".nsigmas"
 
-                if not name1 in self.model.details:
+                if name1 not in self.model.details:
                     self.model.details[name1] = ["", None, None]
 
@@ -855,5 +848,5 @@
 
                         self.sizer4_4.Add(ctl1, (iy, ix), (1, 1), wx.EXPAND)
-                        ## text to show error sign
+                        # text to show error sign
                         ix = 2
                         text2 = wx.StaticText(self, wx.ID_ANY, '+/-')
@@ -968,5 +961,5 @@
 
         self.state.model = self.model.clone()
-        ## save state into
+        # save state into
         self._copy_parameters_state(self.parameters, self.state.parameters)
         self._copy_parameters_state(self.orientation_params_disp,
@@ -978,5 +971,5 @@
         wx.PostEvent(self.parent,
                      StatusEvent(status=" Selected Distribution: Gaussian"))
-        #Fill the list of fittable parameters
+        # Fill the list of fittable parameters
         self.get_all_checked_params()
         self.Layout()
@@ -986,5 +979,5 @@
         Update and Draw the model
         """
-        if self.model == None:
+        if self.model is None:
             msg = "Please select a Model first..."
             wx.MessageBox(msg, 'Info')
@@ -996,7 +989,7 @@
             self.create_default_data()
         """
-        flag,is_modified = self._update_paramv_on_fit()
-
-        wx.CallAfter(self._onparamEnter_helper,is_modified)
+        flag, is_modified = self._update_paramv_on_fit()
+
+        wx.CallAfter(self._onparamEnter_helper, is_modified)
         if not flag:
             msg = "The parameters are invalid"
@@ -1008,5 +1001,5 @@
         Allow to fit
         """
-        if event != None:
+        if event is not None:
             event.Skip()
         if self.fit_started:
@@ -1048,5 +1041,5 @@
             return
 
-        self.select_param(event=None)
+        self.select_param()
 
         # Remove or do not allow fitting on the Q=0 point, especially
@@ -1059,6 +1052,6 @@
                                     qmax=self.qmax_x)
 
-        #single fit
-        #self._manager.onFit(uid=self.uid)
+        # single fit
+        # self._manager.onFit(uid=self.uid)
         self.fit_started = self._manager.onFit(uid=self.uid)
         wx.CallAfter(self.set_fitbutton)
@@ -1073,9 +1066,9 @@
         versions of Wx (before 2.9) and thus not the release version of
         installers, the help comes up at the top level of the file as
-        webbrowser does not pass anything past the # to the browser when it is
+        web browser does not pass anything past the # to the browser when it is
         running "file:///...."
 
-    :param evt: Triggers on clicking the help button
-    """
+        :param evt: Triggers on clicking the help button
+        """
 
         _TreeLocation = "user/sasgui/perspectives/fitting/fitting_help.html"
@@ -1092,9 +1085,9 @@
         versions of Wx (before 2.9) and thus not the release version of
         installers, the help comes up at the top level of the file as
-        webbrowser does not pass anything past the # to the browser when it is
+        web browser does not pass anything past the # to the browser when it is
         running "file:///...."
 
-    :param evt: Triggers on clicking the help button
-    """
+        :param evt: Triggers on clicking the help button
+        """
 
         _TreeLocation = "user/sasgui/perspectives/fitting/sm_help.html"
@@ -1108,5 +1101,5 @@
         """
         # Skip this feature if we are not on Windows
-        #NOTE: the is_mac data member actually means "is no Windows".
+        # NOTE: the is_mac data member actually means "is no Windows".
         if self.is_mac:
             return
@@ -1118,5 +1111,5 @@
             label = "Fit"
             color = "black"
-        #self.btFit.Enable(False)
+        # self.btFit.Enable(False)
         self.btFit.SetLabel(label)
         self.btFit.SetForegroundColour(color)
@@ -1149,5 +1142,5 @@
         Stop fit
         """
-        if event != None:
+        if event is not None:
             event.Skip()
         self._manager.stop_fit(self.uid)
@@ -1169,6 +1162,6 @@
         copy_flag = False
         is_poly_enabled = None
-        if event != None:
-            if (event.GetEventObject() == self.formfactorbox\
+        if event is not None:
+            if (event.GetEventObject() == self.formfactorbox
                         and self.structurebox.GetLabel() != 'None')\
                         or event.GetEventObject() == self.structurebox\
@@ -1183,5 +1176,4 @@
             self._keep.Enable(False)
             self._set_save_flag(False)
-        # TODO: why do we have to variables for one flag??
         self.enable_disp.SetValue(False)
         self.disable_disp.SetValue(True)
@@ -1213,4 +1205,5 @@
                     self._keep.Enable(not self.batch_on)
                     self._set_save_flag(True)
+                    self._set_smear(self.data)
 
             # more disables for 2D
@@ -1226,11 +1219,10 @@
             except:
                 raise
-                ## error occured on chisqr computation
-                #pass
-            ## event to post model to fit to fitting plugins
+                # error occured on chisqr computation
+                # pass
+            # event to post model to fit to fitting plugins
             (ModelEventbox, EVT_MODEL_BOX) = wx.lib.newevent.NewEvent()
 
-            ## set smearing value whether or not
-            #    the data contain the smearing info
+            # set smearing value whether or not data contain the smearing info
             evt = ModelEventbox(model=self.model,
                             smearer=temp_smear,
@@ -1242,14 +1234,15 @@
 
             self._manager._on_model_panel(evt=evt)
-            self.mbox_description.SetLabel("Model [ %s ]" % str(self.model.name))
+            self.mbox_description.SetLabel("Model [ %s ]" %
+                                           str(self.model.name))
             self.mbox_description.SetForegroundColour(wx.BLUE)
             self.state.model = self.model.clone()
             self.state.model.name = self.model.name
 
-        if event != None:
-            ## post state to fit panel
+        if event is not None:
+            # post state to fit panel
             new_event = PageInfoEvent(page=self)
             wx.PostEvent(self.parent, new_event)
-            #update list of plugins if new plugin is available
+            # update list of plugins if new plugin is available
             custom_model = 'Customized Models'
             mod_cat = self.categorybox.GetStringSelection()
@@ -1264,5 +1257,5 @@
                     self.formfactorbox.SetValue(current_val)
             # when select a model only from guictr/button
-            if is_poly_enabled != None:
+            if is_poly_enabled is not None:
                 self.enable_disp.SetValue(is_poly_enabled)
                 self.disable_disp.SetValue(not is_poly_enabled)
@@ -1292,15 +1285,15 @@
         when enter value on panel redraw model according to changed
         """
-        if self.model == None:
+        if self.model is None:
             msg = "Please select a Model first..."
             wx.MessageBox(msg, 'Info')
             return
 
-        #default flag
+        # default flag
         flag = False
         self.fitrange = True
-        #get event object
+        # get event object
         tcrtl = event.GetEventObject()
-        #Clear msg if previously shown.
+        # Clear msg if previously shown.
         msg = ""
         wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
@@ -1313,6 +1306,6 @@
                 if not self.disable_smearer.GetValue():
                     temp_smearer = self.current_smearer
-                    ## set smearing value whether or not
-                    #        the data contain the smearing info
+                    # set smearing value whether or not data contain the
+                    # smearing info
                     if self.slit_smearer.GetValue():
                         flag1 = self.update_slit_smear()
@@ -1331,9 +1324,9 @@
                                               enable_smearer=enable_smearer)
                 if flag:
-                    #self.compute_chisqr(smearer= temp_smearer)
-
-                    ## new state posted
+                    # self.compute_chisqr(smearer= temp_smearer)
+
+                    # new state posted
                     if self.state_change:
-                        #self._undo.Enable(True)
+                        # self._undo.Enable(True)
                         event = PageInfoEvent(page=self)
                         wx.PostEvent(self.parent, event)
@@ -1345,5 +1338,5 @@
         else:
             self.save_current_state()
-            msg = "Cannot Plot :Must enter a number!!!  "
+            msg = "Cannot Plot: Must enter a number!!!  "
             wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
 
@@ -1356,5 +1349,5 @@
         """
         tcrtl = event.GetEventObject()
-        #Clear msg if previously shown.
+        # Clear msg if previously shown.
         msg = ""
         wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
@@ -1374,5 +1367,5 @@
             tcrtl.SetBackgroundColour(wx.WHITE)
 
-        #self._undo.Enable(True)
+        # self._undo.Enable(True)
         self.save_current_state()
         event = PageInfoEvent(page=self)
@@ -1384,7 +1377,7 @@
         ON Qrange focus
         """
-        if event != None:
+        if event is not None:
             event.Skip()
-        #tcrtl = event.GetEventObject()
+        # tcrtl = event.GetEventObject()
         self._validate_qrange(self.qmin, self.qmax)
 
@@ -1393,5 +1386,5 @@
         On Qrange textctrl click, make the qrange lines in the plot
         """
-        if event != None:
+        if event is not None:
             event.Skip()
         if self.data.__class__.__name__ == "Data2D":
@@ -1411,5 +1404,5 @@
         #On q range value updated. DO not combine with qrange_click().
         """
-        if event != None:
+        if event is not None:
             event.Skip()
         if self.data.__class__.__name__ == "Data2D":
@@ -1439,5 +1432,5 @@
         length = len(self.data.x)
         indx = (numpy.abs(self.data.x - x_data)).argmin()
-        #return array.flat[idx]
+        # return array.flat[idx]
         if key == wx.WXK_PAGEUP or key == wx.WXK_NUMPAD_PAGEUP:
             indx += 1
@@ -1458,5 +1451,5 @@
         """
         tcrtl = event.GetEventObject()
-        #Clear msg if previously shown.
+        # Clear msg if previously shown.
         msg = ""
         wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
@@ -1488,5 +1481,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).
             # check for 2d
             if self.data.__class__.__name__ == "Data2D" or \
@@ -1495,6 +1488,5 @@
                 radius = numpy.sqrt(self.data.qx_data * self.data.qx_data +
                                     self.data.qy_data * self.data.qy_data)
-                index_data = ((self.qmin_x <= radius) & \
-                                (radius <= self.qmax_x))
+                index_data = ((self.qmin_x <= radius) & (radius <= self.qmax_x))
                 index_data = (index_data) & (self.data.mask)
                 index_data = (index_data) & (numpy.isfinite(self.data.data))
@@ -1506,9 +1498,9 @@
                     return
                 else:
-                    #self.data.mask = index_data
-                    #self.Npts_fit.SetValue(str(len(self.data.mask)))
+                    # self.data.mask = index_data
+                    # self.Npts_fit.SetValue(str(len(self.data.mask)))
                     self.show_npts2fit()
             else:
-                index_data = ((self.qmin_x <= self.data.x) & \
+                index_data = ((self.qmin_x <= self.data.x) &
                               (self.data.x <= self.qmax_x))
                 self.Npts_fit.SetValue(str(len(self.data.x[index_data])))
@@ -1543,5 +1535,5 @@
             for item in self.parameters:
                 if item[0].IsShown():
-                    #Skip the angle parameters if 1D data
+                    # Skip the angle parameters if 1D data
                     if self.data.__class__.__name__ != "Data2D" and \
                             not self.enable2D:
@@ -1550,11 +1542,11 @@
                     if item in self.param_toFit:
                         continue
-                    ## hide statictext +/-
+                    # hide statictext +/-
                     if len(item) < 4:
                         continue
-                    if item[3] != None and item[3].IsShown():
+                    if item[3] is not None and item[3].IsShown():
                         item[3].Hide()
-                    ## hide textcrtl  for error after fit
-                    if item[4] != None and item[4].IsShown():
+                    # hide textcrtl  for error after fit
+                    if item[4] is not None and item[4].IsShown():
                         item[4].Hide()
 
@@ -1562,5 +1554,5 @@
             for item in self.fittable_param:
                 if item[0].IsShown():
-                    #Skip the angle parameters if 1D data
+                    # Skip the angle parameters if 1D data
                     if self.data.__class__.__name__ != "Data2D" and \
                             not self.enable2D:
@@ -1571,9 +1563,9 @@
                     if len(item) < 4:
                         continue
-                    ## hide statictext +/-
-                    if item[3] != None and item[3].IsShown():
+                    # hide statictext +/-
+                    if item[3] is not None and item[3].IsShown():
                         item[3].Hide()
-                    ## hide textcrtl  for error after fit
-                    if item[4] != None and item[4].IsShown():
+                    # hide textcrtl  for error after fit
+                    if item[4] is not None and item[4].IsShown():
                         item[4].Hide()
         return
@@ -1584,11 +1576,11 @@
         """
         # get the default values
-        if self.dxl == None:
+        if self.dxl is None:
             self.dxl = 0.0
-        if self.dxw == None:
+        if self.dxw is None:
             self.dxw = ""
-        if self.dx_min == None:
+        if self.dx_min is None:
             self.dx_min = SMEAR_SIZE_L
-        if self.dx_max == None:
+        if self.dx_max is None:
             self.dx_max = SMEAR_SIZE_H
 
@@ -1611,7 +1603,7 @@
         elif self.data.__class__.__name__ == "Data2D" or \
             self.enable2D:
-            if data.dqx_data == None or  data.dqy_data == None:
+            if data.dqx_data is None or data.dqy_data is None:
                 return
-            elif self.current_smearer != None \
+            elif self.current_smearer is not None \
                 and data.dqx_data.any() != 0 \
                 and data.dqx_data.any() != 0:
@@ -1623,5 +1615,5 @@
                 return
         # check if it is pinhole smear and get min max if it is.
-        if data.dx != None and all(data.dx != 0):
+        if data.dx is not None and not numpy.any(data.dx):
             self.smear_type = "Pinhole"
             self.dq_l = data.dx[0]
@@ -1629,11 +1621,11 @@
 
         # check if it is slit smear and get min max if it is.
-        elif data.dxl != None or data.dxw != None:
+        elif data.dxl is not None or data.dxw is not None:
             self.smear_type = "Slit"
-            if data.dxl != None and all(data.dxl != 0):
+            if data.dxl is not None and not numpy.all(data.dxl, 0):
                 self.dq_l = data.dxl[0]
-            if data.dxw != None and all(data.dxw != 0):
+            if data.dxw is not None and not numpy.all(data.dxw, 0):
                 self.dq_r = data.dxw[0]
-        #return self.smear_type,self.dq_l,self.dq_r
+        # return self.smear_type,self.dq_l,self.dq_r
 
     def _show_smear_sizer(self):
@@ -1659,5 +1651,5 @@
 
             self.smear_description_dqdata.Show(True)
-            if self.smear_type != None:
+            if self.smear_type is not None:
                 self.smear_description_smear_type.Show(True)
                 if self.smear_type == 'Slit':
@@ -1750,7 +1742,7 @@
         Select an accuracy in 2D custom smear: Xhigh, High, Med, or Low
         """
-        #event.Skip()
+        # event.Skip()
         # Check if the accuracy is same as before
-        #self.smear2d_accuracy = event.GetEventObject().GetValue()
+        # self.smear2d_accuracy = event.GetEventObject().GetValue()
         self.smear2d_accuracy = self.smear_accuracy.GetValue()
         if self.pinhole_smearer.GetValue():
@@ -1758,5 +1750,5 @@
         else:
             self.onSmear(event=None)
-            if self.current_smearer != None:
+            if self.current_smearer is not None:
                 self.current_smearer.set_accuracy(accuracy=\
                                                   self.smear2d_accuracy)
@@ -1790,6 +1782,6 @@
         Build a panel to allow to edit Mask
         """
-        from sas.sasgui.guiframe.local_perspectives.plotting.masking \
-        import MaskPanel as MaskDialog
+        from sas.sasgui.guiframe.local_perspectives.plotting.masking import \
+            MaskPanel as MaskDialog
 
         self.panel = MaskDialog(base=self, data=self.data, id=wx.NewId())
@@ -1802,5 +1794,5 @@
         is_valid_qrange = self._update_paramv_on_fit()
 
-        if is_valid_qrange and self.model != None:
+        if is_valid_qrange and self.model is not None:
             self.panel.MakeModal(False)
             event.Skip()
@@ -1808,5 +1800,5 @@
             self._draw_model()
             self.show_npts2fit()
-        elif self.model == None:
+        elif self.model is None:
             self.panel.MakeModal(False)
             event.Skip()
@@ -1875,5 +1867,5 @@
                     npts = len(data.x)
                 except:
-                    msg = "Unable to find min/max/length of \n data named %s" % \
+                    msg = "Unable to find min/max/length of \n data named %s" %\
                                 data.filename
                     wx.PostEvent(self._manager.parent, StatusEvent(status=msg,
@@ -1892,5 +1884,5 @@
                                                info="error"))
                     raise ValueError, msg
-                ## Maximum value of data
+                # Maximum value of data
                 qmax = math.sqrt(x * x + y * y)
                 npts = len(data.data)
@@ -1904,4 +1896,5 @@
         flag = False
         is_data = False
+        npts = 0
         try:
             old_id = self.data.id
@@ -1915,5 +1908,4 @@
                 flag = True
         if data is not None:
-            id = data.id
             if is_data:
                 self.graph_id = self.data.group_id
@@ -1930,5 +1922,5 @@
             self._set_save_flag(False)
         else:
-            if self.model != None:
+            if self.model is not None:
                 self._set_bookmark_flag(not self.batch_on)
                 self._keep.Enable(not self.batch_on)
@@ -1937,5 +1929,4 @@
                 self._set_preview_flag(True)
 
-            self._set_smear(data)
             # more disables for 2D
             if self.data.__class__.__name__ == "Data2D" or \
@@ -1944,7 +1935,7 @@
                 self.pinhole_smearer.Enable(True)
                 self.default_mask = copy.deepcopy(self.data.mask)
-                if self.data.err_data == None or\
-                        (self.data.err_data == 1).all() or\
-                        (self.data.err_data == 0).all():
+                if self.data.err_data is None or\
+                        numpy.all(err == 1 for err in self.data.err_data) or \
+                        not numpy.any(self.data.err_data):
                     self.dI_didata.Enable(False)
                     self.dI_noweight.SetValue(True)
@@ -1957,7 +1948,8 @@
                 self.slit_smearer.Enable(True)
                 self.pinhole_smearer.Enable(True)
-                if self.data.dy == None or\
-                     (self.data.dy == 1).all() or\
-                     (self.data.dy == 0).all():
+
+                if self.data.dy is None or\
+                     numpy.all(self.data.dy == 1) or\
+                     not numpy.any(self.data.dy):
                     self.dI_didata.Enable(False)
                     self.dI_noweight.SetValue(True)
@@ -1967,5 +1959,5 @@
                     self.dI_didata.SetValue(True)
                     self.weightbt_string = self.dI_didata.GetLabelText()
-            # Enable weighting radio uttons
+            # Enable weighting radio buttons
             self.dI_noweight.Enable(True)
             self.dI_sqrdata.Enable(True)
@@ -1976,5 +1968,5 @@
             data_name = self.data.name
             _, _, npts = self.compute_data_range(self.data)
-            #set maximum range for x in linear scale
+            # set maximum range for x in linear scale
             if not hasattr(self.data, "data"):  # Display only for 1D data fit
                 self.btEditMask.Disable()
@@ -1985,8 +1977,8 @@
 
         self.Npts_total.SetValue(str(npts))
-        #default:number of data points selected to fit
+        # default:number of data points selected to fit
         self.Npts_fit.SetValue(str(npts))
         self.Npts_total.SetEditable(False)
-        self.Npts_total.SetBackgroundColour(\
+        self.Npts_total.SetBackgroundColour(
                                     self.GetParent().GetBackgroundColour())
 
@@ -1998,5 +1990,5 @@
         # send graph_id to page_finder
         self._manager.set_graph_id(uid=self.uid, graph_id=self.graph_id)
-        #focus the page
+        # focus the page
         if check_data_validity(data):
             self.data_box_description.SetForegroundColour(wx.BLUE)
@@ -2010,9 +2002,6 @@
         self.on_set_focus(None)
         self.Refresh()
-        #update model plot with new data information
+        # update model plot with new data information
         if flag:
-            #set model view button
-            self.onSmear(None)
-
             if self.data.__class__.__name__ == "Data2D":
                 self.enable2D = True
@@ -2022,6 +2011,6 @@
                 self.model_view.SetLabel("1D Mode")
             self.model_view.Disable()
-            #replace data plot on combo box selection
-            #by removing the previous selected data
+            #  replace data plot on combo box selection
+            # by removing the previous selected data
             try:
                 wx.PostEvent(self._manager.parent,
@@ -2030,5 +2019,5 @@
             except:
                 pass
-            #plot the current selected data
+            # plot the current selected data
             wx.PostEvent(self._manager.parent,
                          NewPlotEvent(action="check", plot=self.data,
@@ -2050,6 +2039,6 @@
             self.reset_page_helper(state)
 
-            self.select_param(event=None)
-            #Save state_fit
+            self.select_param()
+            # Save state_fit
             self.save_current_state_fit()
         except:
@@ -2090,5 +2079,5 @@
         else:
             for qx in self.data.x:
-                if qx >= qmin and qx <= qmax:
+                if qmax >= qx >= qmin:
                     npts2fit += 1
         return npts2fit
@@ -2119,5 +2108,5 @@
         # make sure stop button to fit button all the time
         self._on_fit_complete()
-        if out == None or not numpy.isfinite(chisqr):
+        if out is None or not numpy.isfinite(chisqr):
             raise ValueError, "Fit error occured..."
 
@@ -2126,10 +2115,10 @@
         dispersity = ''
 
-        #Hide textctrl boxes of errors.
+        # Hide textctrl boxes of errors.
         self._clear_Err_on_Fit()
 
-        #Check if chi2 is finite
-        if chisqr != None and numpy.isfinite(chisqr):
-            #format chi2
+        # Check if chi2 is finite
+        if chisqr is not None and numpy.isfinite(chisqr):
+            # format chi2
             chi2 = format_number(chisqr, True)
             self.tcChi.SetValue(chi2)
@@ -2138,5 +2127,5 @@
             self.tcChi.SetValue("-")
 
-        #Hide error title
+        # Hide error title
         if self.text2_3.IsShown() and not self.is_mac:
             self.text2_3.Hide()
@@ -2145,5 +2134,5 @@
             if self.enable_disp.GetValue():
                 if hasattr(self, "text_disp_1"):
-                    if self.text_disp_1 != None and not self.is_mac:
+                    if self.text_disp_1 is not None and not self.is_mac:
                         self.text_disp_1.Hide()
         except:
@@ -2152,11 +2141,11 @@
 
         i = 0
-        #Set the panel when fit result are list
+        # Set the panel when fit result are list
 
         for item in self.param_toFit:
-            if len(item) > 5 and item != None:
+            if len(item) > 5 and item is not None:
 
                 if item[0].IsShown():
-                    ## reset error value to initial state
+                    # reset error value to initial state
                     if not self.is_mac:
                         item[3].Hide()
@@ -2165,24 +2154,24 @@
                         if item[1] == p_name[ind]:
                             break
-                    if len(out) > 0 and out[ind] != None:
+                    if len(out) > 0 and out[ind] is not None:
                         val_out = format_number(out[ind], True)
                         item[2].SetValue(val_out)
 
-                    if(cov != None and len(cov) == len(out)):
+                    if(cov is not None and len(cov) == len(out)):
                         try:
-                            if dispersity != None:
+                            if dispersity is not None:
                                 if self.enable_disp.GetValue():
                                     if hasattr(self, "text_disp_1"):
-                                        if self.text_disp_1 != None:
+                                        if self.text_disp_1 is not None:
                                             if not self.text_disp_1.IsShown()\
-                                                and not self.is_mac:
+                                                  and not self.is_mac:
                                                 self.text_disp_1.Show(True)
                         except:
                             pass
 
-                        if cov[ind] != None:
+                        if cov[ind] is not None:
                             if numpy.isfinite(float(cov[ind])):
                                 val_err = format_number(cov[ind], True)
-				item[4].SetForegroundColour(wx.BLACK)
+                                item[4].SetForegroundColour(wx.BLACK)
                             else:
                                 val_err = 'NaN'
@@ -2196,9 +2185,9 @@
             else:
                 raise ValueError, "onsetValues: Invalid parameters..."
-        #Show error title when any errors displayed
+        # Show error title when any errors displayed
         if has_error:
             if not self.text2_3.IsShown():
                 self.text2_3.Show(True)
-        ## save current state
+        # save current state
         self.save_current_state()
 
@@ -2207,5 +2196,5 @@
             self.Refresh()
         self._mac_sleep(0.1)
-        #plot model ( when drawing, do not update chisqr value again)
+        # plot model ( when drawing, do not update chisqr value again)
         self._draw_model(update_chisqr=False, source='fit')
 
@@ -2223,5 +2212,5 @@
         # compute weight for the current data
         flag_weight = self.get_weight_flag()
-        if is_2D == None:
+        if is_2D is None:
             is_2D = self._is_2D()
         self._manager.set_fit_weight(uid=self.uid,
@@ -2242,8 +2231,8 @@
         self._update_paramv_on_fit()
 
-        if event != None:
+        if event is not None:
             tcrtl = event.GetEventObject()
             # event case of radio button
-            if tcrtl.GetValue() == True:
+            if tcrtl.GetValue():
                 self.dx_min = 0.0
                 self.dx_max = 0.0
@@ -2263,13 +2252,13 @@
 
         self.sizer_set_smearer.Layout()
-        ## we need FitInside here not just self.Layout to ensure all the sizers
-        ## end up with the necessasary space to in the scroll panel. In
-        ## particular the compute and fit buttons end up on top of each other
-        ## PDB Nov 28 2015. 
+        # we need FitInside here not just self.Layout to ensure all the sizers
+        # end up with the necessasary space to in the scroll panel. In
+        # particular the compute and fit buttons end up on top of each other
+        # PDB Nov 28 2015.
         self.FitInside()
 
-        if event != None:
+        if event is not None:
             event.Skip()
-        #self._undo.Enable(True)
+        # self._undo.Enable(True)
         self.save_current_state()
         event = PageInfoEvent(page=self)
@@ -2346,5 +2335,5 @@
                 get_pin_max.SetBackgroundColour("pink")
                 msg = "Model Error:This value can not be negative!!!"
-            elif self.dx_min != None and self.dx_max != None:
+            elif self.dx_min is not None and self.dx_max is not None:
                 if self._is_2D():
                     data.dqx_data[data.dqx_data == 0] = self.dx_min
@@ -2357,10 +2346,10 @@
                                            self.dx_max + step / 1.1,
                                            step)
-            elif self.dx_min != None:
+            elif self.dx_min is not None:
                 if self._is_2D():
                     data.dqx_data[data.dqx_data == 0] = self.dx_min
                 else:
                     data.dx[data.dx == 0] = self.dx_min
-            elif self.dx_max != None:
+            elif self.dx_max is not None:
                 if self._is_2D():
                     data.dqy_data[data.dqy_data == 0] = self.dx_max
@@ -2370,13 +2359,13 @@
             # 2D need to set accuracy
             if self._is_2D():
-                self.current_smearer.set_accuracy(accuracy=\
-                                                  self.smear2d_accuracy)
-
-        if msg != None:
+                self.current_smearer.set_accuracy(
+                    accuracy=self.smear2d_accuracy)
+
+        if msg is not None:
             wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
         else:
             get_pin_min.SetBackgroundColour("white")
             get_pin_max.SetBackgroundColour("white")
-        ## set smearing value whether or not the data contain the smearing info
+        # set smearing value whether or not the data contain the smearing info
 
         enable_smearer = not self.disable_smearer.GetValue()
@@ -2404,5 +2393,5 @@
         wx.CallAfter(self.save_current_state)
 
-        if msg != None:
+        if msg is not None:
             return False
         else:
@@ -2420,5 +2409,5 @@
         msg = None
         # for event given
-        if event != None:
+        if event is not None:
             tcrtl = event.GetEventObject()
             # event case of radio button
@@ -2441,16 +2430,16 @@
         self._show_smear_sizer()
         self.sizer_set_smearer.Layout()
-        ## we need FitInside here not just self.Layout to ensure all the sizers
-        ## end up with the necessasary space to in the scroll panel. In
-        ## particular the compute and fit buttons end up on top of each other
-        ## PDB Nov 28 2015. 
+        # we need FitInside here not just self.Layout to ensure all the sizers
+        # end up with the necessasary space to in the scroll panel. In
+        # particular the compute and fit buttons end up on top of each other
+        # PDB Nov 28 2015.
         self.FitInside()
 
-        if event != None:
+        if event is not None:
             event.Skip()
         self.save_current_state()
         event = PageInfoEvent(page=self)
         wx.PostEvent(self.parent, event)
-        if msg != None:
+        if msg is not None:
             wx.PostEvent(self._manager.parent, StatusEvent(status=msg))
 
@@ -2541,5 +2530,5 @@
 
         self.current_smearer = smear_selection(data, self.model)
-        ## set smearing value whether or not the data contain the smearing info
+        # set smearing value whether or not the data contain the smearing info
         enable_smearer = not self.disable_smearer.GetValue()
         self._manager.set_smearer(smearer=self.current_smearer,
@@ -2564,8 +2553,8 @@
         if self._is_changed_slit():
             msg = self._set_slit_smear()
-        #self._undo.Enable(True)
+        # self._undo.Enable(True)
         self.save_current_state()
 
-        if msg != None:
+        if msg is not None:
             return False
         else:
@@ -2577,5 +2566,5 @@
         are computed when fitting
         """
-        if event != None:
+        if event is not None:
             event.Skip()
         if self.data is None:
@@ -2590,12 +2579,12 @@
 
         self.sizer_set_smearer.Layout()
-        ## we need FitInside here not just self.Layout to ensure all the sizers
-        ## end up with the necessasary space to in the scroll panel. In
-        ## particular the compute and fit buttons end up on top of each other
-        ## PDB Nov 28 2015. 
+        # we need FitInside here not just self.Layout to ensure all the sizers
+        # end up with the necessasary space to in the scroll panel. In
+        # particular the compute and fit buttons end up on top of each other
+        # PDB Nov 28 2015.
         self.FitInside()
         self._set_weight()
 
-        ## set smearing value whether or not the data contain the smearing info
+        # set smearing value whether or not the data contain the smearing info
         enable_smearer = not self.disable_smearer.GetValue()
         wx.CallAfter(self._manager.set_smearer, uid=self.uid,
@@ -2618,5 +2607,5 @@
         """
         self._get_smear_info()
-        #renew smear sizer
+        # renew smear sizer
         if self.smear_type is not None:
             self.smear_description_smear_type.SetValue(str(self.smear_type))
@@ -2658,5 +2647,5 @@
         """
         try:
-            if event == None:
+            if event is None:
                 output = "-"
             elif not numpy.isfinite(event.output):
@@ -2693,5 +2682,5 @@
         self._manager.set_param2fit(self.uid, param2fit)
 
-    def select_param(self, event):
+    def select_param(self, event=None):
         """
         Select TextCtrl  checked for fitting purpose and stores them
@@ -2700,10 +2689,10 @@
         self.param_toFit = []
         for item in self.parameters:
-            #Skip t ifhe angle parameters if 1D data
+            # Skip t ifhe angle parameters if 1D data
             if self.data.__class__.__name__ != "Data2D" and\
                         not self.enable2D:
                 if item in self.orientation_params:
                     continue
-            #Select parameters to fit for list of primary parameters
+            # Select parameters to fit for list of primary parameters
             if item[0].GetValue() and item[0].IsShown():
                 if not (item in self.param_toFit):
@@ -2714,8 +2703,8 @@
                     self.param_toFit.remove(item)
 
-        #Select parameters to fit for list of fittable parameters
+        # Select parameters to fit for list of fittable parameters
         #        with dispersion
         for item in self.fittable_param:
-            #Skip t ifhe angle parameters if 1D data
+            # Skip t ifhe angle parameters if 1D data
             if self.data.__class__.__name__ != "Data2D" and\
                         not self.enable2D:
@@ -2726,9 +2715,9 @@
                     self.param_toFit.append(item)
             else:
-                #remove parameters from the fitting list
+                # remove parameters from the fitting list
                 if item in self.param_toFit:
                     self.param_toFit.remove(item)
 
-        #Calculate num. of angle parameters
+        # Calculate num. of angle parameters
         if self.data.__class__.__name__ == "Data2D" or \
                        self.enable2D:
@@ -2736,11 +2725,11 @@
         else:
             len_orient_para = len(self.orientation_params)  # assume even len
-        #Total num. of angle parameters
+        # Total num. of angle parameters
         if len(self.fittable_param) > 0:
             len_orient_para *= 2
 
         self.save_current_state_fit()
-        if event != None:
-            ## post state to fit panel
+        if event is not None:
+            # post state to fit panel
             event = PageInfoEvent(page=self)
             wx.PostEvent(self.parent, event)
@@ -2768,5 +2757,5 @@
         self.orientation_params_disp = []
 
-        if model == None:
+        if model is None:
             self.sizer3.Layout()
             self.SetupScrolling()
@@ -2776,10 +2765,10 @@
         boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)
         sizer = wx.GridBagSizer(5, 5)
-        ## save the current model
+        # save the current model
         self.model = model
 
         keys = self.model.getParamList()
 
-        #list of dispersion parameters
+        # list of dispersion parameters
         self.disp_list = self.model.getDispParamList()
 
@@ -2814,5 +2803,5 @@
                 return -1
             # both have a number
-            if num_a != None and num_b != None:
+            if num_a is not None and num_b is not None:
                 if num_a > num_b:
                     return -1
@@ -2827,7 +2816,7 @@
                     return 1
             # one of them has a number
-            elif num_a != None:
+            elif num_a is not None:
                 return 1
-            elif num_b != None:
+            elif num_b is not None:
                 return -1
             # no numbers
@@ -2835,6 +2824,6 @@
                 return cmp(a.lower(), b.lower())
         
-        # keys obtained now from ordered dict, so commenting alphabetical ordering
-        #keys.sort(custom_compare)
+        # keys obtained now from ordered dict, so commenting alphabetical
+        # ordering keys.sort(custom_compare)
 
         iy = 0
@@ -2844,26 +2833,26 @@
         ix += 1
         self.text2_2 = wx.StaticText(self, wx.ID_ANY, 'Value')
-        sizer.Add(self.text2_2, (iy, ix), (1, 1), \
+        sizer.Add(self.text2_2, (iy, ix), (1, 1),
                             wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         ix += 2
         self.text2_3 = wx.StaticText(self, wx.ID_ANY, 'Error')
-        sizer.Add(self.text2_3, (iy, ix), (1, 1), \
-                            wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        sizer.Add(self.text2_3, (iy, ix), (1, 1),
+                  wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         if not self.is_mac:
             self.text2_3.Hide()
         ix += 1
         self.text2_min = wx.StaticText(self, wx.ID_ANY, 'Min')
-        sizer.Add(self.text2_min, (iy, ix), (1, 1), \
-                            wx.EXPAND | wx.ADJUST_MINSIZE, 0)
-        #self.text2_min.Hide()
+        sizer.Add(self.text2_min, (iy, ix), (1, 1),
+                  wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        # self.text2_min.Hide()
         ix += 1
         self.text2_max = wx.StaticText(self, wx.ID_ANY, 'Max')
-        sizer.Add(self.text2_max, (iy, ix), (1, 1), \
-                            wx.EXPAND | wx.ADJUST_MINSIZE, 0)
-        #self.text2_max.Hide()
+        sizer.Add(self.text2_max, (iy, ix), (1, 1),
+                  wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        # self.text2_max.Hide()
         ix += 1
         self.text2_4 = wx.StaticText(self, wx.ID_ANY, '[Units]')
-        sizer.Add(self.text2_4, (iy, ix), (1, 1), \
-                            wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        sizer.Add(self.text2_4, (iy, ix), (1, 1),
+                  wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         self.text2_4.Hide()
 
@@ -2871,30 +2860,30 @@
         for item in keys:
 
-            if not item in self.disp_list and not item in \
+            if item not in self.disp_list and not item in \
                     self.model.orientation_params:
 
-                ##prepare a spot to store errors
-                if not item in self.model.details:
+                # prepare a spot to store errors
+                if item not in self.model.details:
                     self.model.details[item] = ["", None, None]
 
                 iy += 1
                 ix = 0
-                if (self.model.__class__ in \
-                    self.model_list_box["Multi-Functions"] or \
+                if (self.model.__class__ in
+                    self.model_list_box["Multi-Functions"] or
                     self.temp_multi_functional)\
                     and (item in self.model.non_fittable):
                     non_fittable_name = wx.StaticText(self, wx.ID_ANY, item)
-                    sizer.Add(non_fittable_name, (iy, ix), (1, 1), \
+                    sizer.Add(non_fittable_name, (iy, ix), (1, 1),
                             wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 21)
-                    ## add parameter value
+                    # add parameter value
                     ix += 1
                     value = self.model.getParam(item)
                     if len(self.model.fun_list) > 0:
-                        #num = item.split('_')[1][5:7]
+                        # num = item.split('_')[1][5:7]
                         fun_box = wx.ComboBox(self, wx.ID_ANY, size=(100, -1),
                                     style=wx.CB_READONLY, name='%s' % item)
                         self._set_fun_box_list(fun_box)
                         fun_box.SetSelection(0)
-                        #self.fun_box.SetToolTipString("A function
+                        # self.fun_box.SetToolTipString("A function
                         #    describing the interface")
                         wx.EVT_COMBOBOX(fun_box, wx.ID_ANY, self._on_fun_box)
@@ -2903,5 +2892,5 @@
                                                 size=(_BOX_WIDTH, 20),
                                 style=wx.TE_PROCESS_ENTER, name='%s' % item)
-                        fun_box.SetToolTipString(\
+                        fun_box.SetToolTipString(
                                 "Hit 'Enter' after typing to update the plot.")
                         fun_box.SetValue(format_number(value, True))
@@ -2911,9 +2900,9 @@
                                                 None, None])
                 else:
-                    ## add parameters name with checkbox for selecting to fit
+                    # add parameters name with checkbox for selecting to fit
                     cb = wx.CheckBox(self, wx.ID_ANY, item)
                     cb.SetValue(CHECK_STATE)
                     cb.SetToolTipString(" Check mark to fit.")
-                    #cb.SetValue(True)
+                    # cb.SetValue(True)
                     wx.EVT_CHECKBOX(self, cb.GetId(), self.select_param)
 
@@ -2921,17 +2910,17 @@
                               wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 5)
 
-                    ## add parameter value
+                    # add parameter value
                     ix += 1
                     value = self.model.getParam(item)
                     ctl1 = ModelTextCtrl(self, wx.ID_ANY, size=(_BOX_WIDTH, 20),
                                          style=wx.TE_PROCESS_ENTER)
-                    ctl1.SetToolTipString(\
+                    ctl1.SetToolTipString(
                                 "Hit 'Enter' after typing to update the plot.")
                     ctl1.SetValue(format_number(value, True))
                     sizer.Add(ctl1, (iy, ix), (1, 1), wx.EXPAND)
-                    ## text to show error sign
+                    # text to show error sign
                     ix += 1
                     text2 = wx.StaticText(self, wx.ID_ANY, '+/-')
-                    sizer.Add(text2, (iy, ix), (1, 1), \
+                    sizer.Add(text2, (iy, ix), (1, 1),
                               wx.EXPAND | wx.ADJUST_MINSIZE, 0)
                     if not self.is_mac:
@@ -2994,5 +2983,5 @@
         iy += 1
         ix = 0
-        #Add tile for orientational angle
+        # Add tile for orientational angle
         for item in keys:
             if item in self.model.orientation_params:
@@ -3001,10 +2990,11 @@
                 mag_on_button.SetToolTipString("Turn Pol Beam/Mag scatt on/off")
                 mag_on_button.Bind(wx.EVT_BUTTON, self._on_mag_on)
-                mag_angle_help_button = wx.Button(self, wx.ID_ANY, "Magnetic angles?")
+                mag_angle_help_button = wx.Button(self, wx.ID_ANY,
+                                                  "Magnetic angles?")
                 mag_angle_help_button.SetToolTipString("see angle definitions")
                 mag_help_button = wx.Button(self, wx.ID_ANY, "Mag HELP")
                 mag_help_button.SetToolTipString("Help on pol beam/mag fitting")
                 mag_help_button.Bind(wx.EVT_BUTTON, self._on_mag_help)
-                mag_angle_help_button.Bind(wx.EVT_BUTTON, \
+                mag_angle_help_button.Bind(wx.EVT_BUTTON,
                                             self._on_mag_angle_help)
                 sizer.Add(orient_angle, (iy, ix), (1, 1),
@@ -3019,7 +3009,7 @@
                           wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
 
-                #handle the magnetic buttons
-                #clean this up so that assume mag is off then turn 
-                #all buttons on IF mag has mag and has 2D
+                # handle the magnetic buttons
+                # clean this up so that assume mag is off then turn
+                # all buttons on IF mag has mag and has 2D
                 if not self._has_magnetic:
                     mag_on_button.Show(False)
@@ -3047,5 +3037,5 @@
                 break
 
-        #For Gaussian only
+        # For Gaussian only
         if type.lower() != "array":
             for item in self.model.orientation_params:
@@ -3053,12 +3043,12 @@
                     if item in self.model.magnetic_params:
                         continue
-                if not item in self.disp_list:
-                    ##prepare a spot to store min max
-                    if not item in self.model.details:
+                if item not in self.disp_list:
+                    # prepare a spot to store min max
+                    if item not in self.model.details:
                         self.model.details[item] = ["", None, None]
 
                     iy += 1
                     ix = 0
-                    ## add parameters name with checkbox for selecting to fit
+                    # add parameters name with checkbox for selecting to fit
                     cb = wx.CheckBox(self, wx.ID_ANY, item)
                     cb.SetValue(CHECK_STATE)
@@ -3073,10 +3063,10 @@
                               wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 5)
 
-                    ## add parameter value
+                    # add parameter value
                     ix += 1
                     value = self.model.getParam(item)
                     ctl1 = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),
                                          style=wx.TE_PROCESS_ENTER)
-                    ctl1.SetToolTipString(\
+                    ctl1.SetToolTipString(
                                 "Hit 'Enter' after typing to update the plot.")
                     ctl1.SetValue(format_number(value, True))
@@ -3087,8 +3077,8 @@
                         ctl1.Hide()
                     sizer.Add(ctl1, (iy, ix), (1, 1), wx.EXPAND)
-                    ## text to show error sign
+                    # text to show error sign
                     ix += 1
                     text2 = wx.StaticText(self, -1, '+/-')
-                    sizer.Add(text2, (iy, ix), (1, 1), \
+                    sizer.Add(text2, (iy, ix), (1, 1),
                               wx.EXPAND | wx.ADJUST_MINSIZE, 0)
 
@@ -3155,9 +3145,9 @@
         iy += 1
         box_description.SetForegroundColour(wx.BLUE)
-        #Display units text on panel
+        # Display units text on panel
         for item in keys:
             if item in self.model.details:
                 self.text2_4.Show()
-        #Fill the list of fittable parameters
+        # Fill the list of fittable parameters
         self.get_all_checked_params()
         self.save_current_state_fit()
@@ -3171,5 +3161,5 @@
         Get key stroke event
         """
-        if self.data == None:
+        if self.data is None:
             return
         # Figuring out key combo: Cmd for copy, Alt for paste
Index: src/sas/sasgui/perspectives/fitting/fitpanel.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/fitpanel.py	(revision e6de6b8b31744ebe652ab6206d60d0d20979c592)
+++ src/sas/sasgui/perspectives/fitting/fitpanel.py	(revision c8e19964f2dda929ccae8237e7b140a906cdf134)
@@ -187,8 +187,6 @@
         """
 
-        # get number of pages
-        nop = self.GetPageCount()
         # use while-loop, for-loop will not do the job well.
-        while (nop > 0):
+        while (self.GetPageCount() > 0):
             # delete the first page until no page exists
             page = self.GetPage(0)
@@ -197,5 +195,4 @@
             self._close_helper(selected_page=page)
             self.DeletePage(0)
-            nop = self.GetPageCount()
         # Clear list of names
         self.fit_page_name = {}
@@ -240,5 +237,4 @@
         # close all panels only when svs file opened
         self.close_all()
-        self._manager.mypanels = []
         self.sim_page = None
         self.batch_page = None
@@ -248,7 +244,6 @@
         close page and remove all references to the closed page
         """
-        nbr_page = self.GetPageCount()
         selected_page = self.GetPage(self.GetSelection())
-        if nbr_page == 1:
+        if self.GetPageCount() == 1:
             if selected_page.get_data() is not None:
                 if event is not None:
@@ -293,5 +288,5 @@
         copy a dictionary of model into its own dictionary
 
-        :param m_dict: dictionnary made of model name as key and model class
+        :param dict: dictionnary made of model name as key and model class
             as value
         """
@@ -320,5 +315,5 @@
         if caption == "Const & Simul Fit":
             self.sim_page = SimultaneousFitPage(self, page_finder=page_finder,
-                                                 id= wx.ID_ANY, batch_on=False)
+                                                 id=wx.ID_ANY, batch_on=False)
             self.sim_page.window_caption = caption
             self.sim_page.window_name = caption
@@ -397,5 +392,4 @@
             raise ValueError, "Fitpanel delete_data expect list of id"
         else:
-            n = self.GetPageCount()
             for page in self.opened_pages.values():
                 pos = self.GetPageIndex(page)
@@ -441,5 +435,6 @@
         if data_1d_list and data_2d_list:
             # need to warning the user that this batch is a special case
-            from sas.sasgui.perspectives.fitting.fitting_widgets import BatchDataDialog
+            from sas.sasgui.perspectives.fitting.fitting_widgets import \
+                BatchDataDialog
             dlg = BatchDataDialog(self)
             if dlg.ShowModal() == wx.ID_OK:
@@ -461,5 +456,5 @@
                 page = self.add_empty_page()
             if data_1d_list and not data_2d_list:
-                #only on type of data
+                # only on type of data
                 page.fill_data_combobox(data_1d_list)
             elif not data_1d_list and data_2d_list:
@@ -477,5 +472,5 @@
         Add a fitting page on the notebook contained by fitpanel
 
-        :param data: data to fit
+        :param data_list: data to fit
 
         :return panel : page just added for further used.
Index: src/sas/sasgui/perspectives/fitting/pagestate.py
===================================================================
--- src/sas/sasgui/perspectives/fitting/pagestate.py	(revision 467202f2479da030154e3d3657b1bf2642b5b503)
+++ src/sas/sasgui/perspectives/fitting/pagestate.py	(revision c8e19964f2dda929ccae8237e7b140a906cdf134)
@@ -46,6 +46,8 @@
                             ["npts", "npts", "float"],
                             ["categorycombobox", "categorycombobox", "string"],
-                            ["formfactorcombobox", "formfactorcombobox", "string"],
-                            ["structurecombobox", "structurecombobox", "string"],
+                            ["formfactorcombobox", "formfactorcombobox",
+                             "string"],
+                            ["structurecombobox", "structurecombobox",
+                             "string"],
                             ["multi_factor", "multi_factor", "float"],
                             ["magnetic_on", "magnetic_on", "bool"],
@@ -65,6 +67,6 @@
                             ["smearer", "smearer", "float"],
                             ["smear_type", "smear_type", "string"],
-                            ["dq_l", "dq_l", "string"],
-                            ["dq_r", "dq_r", "string"],
+                            ["dq_l", "dq_l", "float"],
+                            ["dq_r", "dq_r", "float"],
                             ["dx_max", "dx_max", "float"],
                             ["dx_min", "dx_min", "float"],
@@ -80,5 +82,6 @@
                             ["str_parameters", "str_parameters"],
                             ["orientation_parameters", "orientation_params"],
-                            ["dispersity_parameters", "orientation_params_disp"],
+                            ["dispersity_parameters",
+                             "orientation_params_disp"],
                             ["fixed_param", "fixed_param"],
                             ["fittable_param", "fittable_param"]]
@@ -120,10 +123,10 @@
             try:
                 return node.get(item[0]).strip() == "True"
-            except:
+            except Exception:
                 return None
         else:
             try:
                 return float(node.get(item[0]))
-            except:
+            except Exception:
                 return None
 
@@ -188,5 +191,5 @@
         # page name
         self.page_name = ""
-        # Contains link between model, all its parameters, and panel organization
+        # Contains link between model, its parameters, and panel organization
         self.parameters = []
         # String parameter list that can not be fitted
@@ -305,5 +308,6 @@
         obj.fittable_param = copy.deepcopy(self.fittable_param)
         obj.orientation_params = copy.deepcopy(self.orientation_params)
-        obj.orientation_params_disp = copy.deepcopy(self.orientation_params_disp)
+        obj.orientation_params_disp = \
+            copy.deepcopy(self.orientation_params_disp)
         obj.enable_disp = copy.deepcopy(self.enable_disp)
         obj.disable_disp = copy.deepcopy(self.disable_disp)
@@ -397,5 +401,5 @@
         rep += "data : %s\n" % str(self.data)
         rep += "Plotting Range: min: %s, max: %s, steps: %s\n" % \
-               (str(self.qmin),str(self.qmax), str(self.npts))
+               (str(self.qmin), str(self.qmax), str(self.npts))
         rep += "Dispersion selection : %s\n" % str(self.disp_box)
         rep += "Smearing enable : %s\n" % str(self.enable_smearer)
@@ -413,8 +417,8 @@
 
         rep += "2D enable : %s\n" % str(self.enable2D)
-        rep += "All parameters checkbox selected: %s\n" % str(self.cb1)
+        rep += "All parameters checkbox selected: %s\n" % self.cb1
         rep += "Value of Chisqr : %s\n" % str(self.tcChi)
-        rep += "Smear object : %s\n" % str(self.smearer)
-        rep += "Smear type : %s\n" % str(self.smear_type)
+        rep += "Smear object : %s\n" % self.smearer
+        rep += "Smear type : %s\n" % self.smear_type
         rep += "dq_l  : %s\n" % self.dq_l
         rep += "dq_r  : %s\n" % self.dq_r
@@ -478,5 +482,5 @@
                 value = content[1]
             except Exception:
-                msg = "Report string expected 'name: value' but got %r"%line
+                msg = "Report string expected 'name: value' but got %r" % line
                 logging.error(msg)
             if name.count("State created"):
@@ -493,9 +497,8 @@
             if name == "value":
                 param_string += value + ','
+            fixed_parameter = False
             if name == "selected":
                 if value == u' False':
                     fixed_parameter = True
-                else:
-                    fixed_parameter = False
             if name == "error value":
                 if fixed_parameter:
@@ -617,5 +620,5 @@
         dialog.Show()
 
-    def _toXML_helper(self, thelist, element, newdoc):
+    def _to_xml_helper(self, thelist, element, newdoc):
         """
         Helper method to create xml file for saving state
@@ -635,6 +638,6 @@
             element.appendChild(sub_element)
 
-    def toXML(self, file="fitting_state.fitv", doc=None,
-              entry_node=None, batch_fit_state=None):
+    def to_xml(self, file="fitting_state.fitv", doc=None,
+               entry_node=None, batch_fit_state=None):
         """
         Writes the state of the fit panel to file, as XML.
@@ -648,4 +651,5 @@
         :param entry_node: XML node within the XML document at which we
                            will append the data [optional]
+        :param batch_fit_state: simultaneous fit state
         """
         from xml.dom.minidom import getDOMImplementation
@@ -746,6 +750,6 @@
         for item in LIST_OF_STATE_PARAMETERS:
             element = newdoc.createElement(item[0])
-            self._toXML_helper(thelist=getattr(self, item[1]),
-                               element=element, newdoc=newdoc)
+            self._to_xml_helper(thelist=getattr(self, item[1]),
+                                element=element, newdoc=newdoc)
             inputs.appendChild(element)
 
@@ -765,5 +769,6 @@
             for constraint in batch_fit_state.constraints_list:
                 if constraint.model_cbox.GetValue() != "":
-                    # model_cbox, param_cbox, egal_txt, constraint, btRemove, sizer
+                    # model_cbox, param_cbox, egal_txt, constraint,
+                    # btRemove, sizer
                     doc_cons = newdoc.createElement('constraint')
                     doc_cons.setAttribute('model_cbox',
@@ -808,5 +813,5 @@
             return newdoc
 
-    def _fromXML_helper(self, node, list):
+    def _from_xml_helper(self, node, list):
         """
         Helper function to write state to xml
@@ -858,5 +863,5 @@
                          [maximum_displayed, maximum_value], unit])
 
-    def fromXML(self, file=None, node=None):
+    def from_xml(self, file=None, node=None):
         """
         Load fitting state from a file
@@ -887,11 +892,11 @@
                     logging.error(msg)
 
-            # Parse fitting attributes
-            entry = get_content('ns:Attributes', node)
-            for item in LIST_OF_DATA_ATTRIBUTES:
-                node = get_content('ns:%s' % item[0], entry)
-                setattr(self, item[0], parse_entry_helper(node, item))
-
             if entry is not None:
+                # Parse fitting attributes
+                entry = get_content('ns:Attributes', node)
+                for item in LIST_OF_DATA_ATTRIBUTES:
+                    node = get_content('ns:%s' % item[0], entry)
+                    setattr(self, item[0], parse_entry_helper(node, item))
+
                 for item in LIST_OF_STATE_ATTRIBUTES:
                     node = get_content('ns:%s' % item[0], entry)
@@ -900,5 +905,6 @@
                 for item in LIST_OF_STATE_PARAMETERS:
                     node = get_content("ns:%s" % item[0], entry)
-                    self._fromXML_helper(node=node, list=getattr(self, item[1]))
+                    self._from_xml_helper(node=node,
+                                          list=getattr(self, item[1]))
 
                 # Recover _disp_obj_dict from xml file
@@ -950,6 +956,4 @@
         """
         images = []
-        # some imports
-        import wx
 
         # Reset memory
@@ -958,5 +962,5 @@
 
         # For no figures in the list, prepare empty plot
-        if figs == None or len(figs) == 0:
+        if figs is None or len(figs) == 0:
             figs = [None]
 
@@ -965,9 +969,9 @@
         self.imgRAM = wx.MemoryFSHandler()
         for fig in figs:
-            if figs != None:
+            if fig is not None:
                 ind = figs.index(fig)
                 canvas = canvases[ind]
 
-            #store the image in wx.FileSystem Object
+            # store the image in wx.FileSystem Object
             wx.FileSystem.AddHandler(wx.MemoryFSHandler())
 
@@ -975,9 +979,9 @@
             ind = figs.index(fig)
 
-            #AddFile, image can be retrieved with 'memory:filename'
+            # AddFile, image can be retrieved with 'memory:filename'
             self.imgRAM.AddFile('img_fit%s.png' % ind,
                                 canvas.bitmap, wx.BITMAP_TYPE_PNG)
 
-            #append figs
+            # append figs
             images.append(fig)
 
@@ -989,11 +993,11 @@
     Class to load a .fitv fitting file
     """
-    ## File type
+    # File type
     type_name = "Fitting"
 
-    ## Wildcards
+    # Wildcards
     type = ["Fitting files (*.fitv)|*.fitv"
             "SASView file (*.svs)|*.svs"]
-    ## List of allowed extensions
+    # List of allowed extensions
     ext = ['.fitv', '.FITV', '.svs', 'SVS']
 
@@ -1009,7 +1013,7 @@
 
         """
-        ## Call back method to be executed after a file is read
+        # Call back method to be executed after a file is read
         self.call_back = call_back
-        ## CanSAS format flag
+        # CanSAS format flag
         self.cansas = cansas
         self.state = None
@@ -1027,5 +1031,5 @@
 
         """
-        if self.cansas == True:
+        if self.cansas:
             return self._read_cansas(path)
 
@@ -1061,5 +1065,5 @@
         for item in datainfo.run:
             runname = {}
-            if datainfo.run_name.has_key(item) and \
+            if item in datainfo.run_name and \
                             len(str(datainfo.run_name[item])) > 1:
                 runname = {'name': datainfo.run_name[item]}
@@ -1076,5 +1080,4 @@
             root_node = doc.createElement(item[0])
             new_node.appendChild(root_node)
-            temp_list = None
             temp_list = getattr(datainfo, item[1])
 
@@ -1113,5 +1116,5 @@
                                        datainfo.sample.position.z,
                                        {"unit": datainfo.sample.position_unit})
-        if written == True:
+        if written:
             sample.appendChild(pos)
 
@@ -1121,9 +1124,11 @@
         written = written | write_node(doc, ori, "pitch",
                                        datainfo.sample.orientation.y,
-                                       {"unit": datainfo.sample.orientation_unit})
+                                       {"unit":
+                                            datainfo.sample.orientation_unit})
         written = written | write_node(doc, ori, "yaw",
                                        datainfo.sample.orientation.z,
-                                       {"unit": datainfo.sample.orientation_unit})
-        if written == True:
+                                       {"unit":
+                                            datainfo.sample.orientation_unit})
+        if written:
             sample.appendChild(ori)
 
@@ -1153,5 +1158,5 @@
                                        datainfo.source.beam_size.z,
                                        {"unit": datainfo.source.beam_size_unit})
-        if written == True:
+        if written:
             source.appendChild(size)
 
@@ -1198,5 +1203,5 @@
                 written = written | write_node(doc, size, "z", apert.size.z,
                                                {"unit": apert.size_unit})
-                if written == True:
+                if written:
                     ap.appendChild(size)
 
@@ -1210,5 +1215,5 @@
                                            item.slit_length,
                                            {"unit": item.slit_length_unit})
-            if written == True:
+            if written:
                 instr.appendChild(det)
 
@@ -1220,5 +1225,5 @@
             written = written | write_node(doc, off, "z", item.offset.z,
                                            {"unit": item.offset_unit})
-            if written == True:
+            if written:
                 det.appendChild(off)
 
@@ -1232,5 +1237,5 @@
                                            item.beam_center.z,
                                            {"unit": item.beam_center_unit})
-            if written == True:
+            if written:
                 det.appendChild(center)
 
@@ -1242,5 +1247,5 @@
             written = written | write_node(doc, pix, "z", item.pixel_size.z,
                                            {"unit": item.pixel_size_unit})
-            if written == True:
+            if written:
                 det.appendChild(pix)
 
@@ -1253,5 +1258,5 @@
             written = written | write_node(doc, ori, "yaw", item.orientation.z,
                                            {"unit": item.orientation_unit})
-            if written == True:
+            if written:
                 det.appendChild(ori)
 
@@ -1290,5 +1295,5 @@
                 # Create an empty state
                 state = PageState()
-                state.fromXML(node=nodes[0])
+                state.from_xml(node=nodes[0])
 
         except:
@@ -1314,12 +1319,13 @@
                 simfitstate_0 = simfitstate[0]
                 all = simfitstate_0.xpath('ns:select_all',
-                                        namespaces={'ns': CANSAS_NS})
+                                          namespaces={'ns': CANSAS_NS})
                 atts = all[0].attrib
                 checked = atts.get('checked')
                 sim_fit_state.select_all = bool(checked)
                 model_list = simfitstate_0.xpath('ns:model_list',
-                                               namespaces={'ns': CANSAS_NS})
+                                                 namespaces={'ns': CANSAS_NS})
                 model_list_items = model_list[0].xpath('ns:model_list_item',
-                                                   namespaces={'ns': CANSAS_NS})
+                                                       namespaces={'ns':
+                                                                    CANSAS_NS})
                 for model in model_list_items:
                     attrs = model.attrib
@@ -1368,5 +1374,5 @@
             return return_value, _
 
-        #Parse 2D
+        # Parse 2D
         data_info = Data2D()
 
@@ -1590,5 +1596,5 @@
         for entry in nodes:
             for item in LIST_OF_DATA_2D_ATTR:
-                #get node
+                # get node
                 node = get_content('ns:%s' % item[0], entry)
                 setattr(data_info, item[1], parse_entry_helper(node, item))
@@ -1633,5 +1639,4 @@
                     entry_list = root.xpath('ns:SASentry',
                                             namespaces={'ns': CANSAS_NS})
-                    name_map = {}
                     for entry in entry_list:
                         try:
@@ -1679,5 +1684,5 @@
                         state.data.is_data = state.is_data
                     if output[ind].run_name is not None\
-                        and len(output[ind].run_name) != 0:
+                         and len(output[ind].run_name) != 0:
                         if isinstance(output[ind].run_name, dict):
                             name = output[ind].run_name.keys()[0]
@@ -1715,5 +1720,5 @@
             # Write the XML document
         else:
-            doc = fitstate.toXML(file=filename)
+            doc = fitstate.to_xml(file=filename)
 
         # Save the document no matter the type
@@ -1749,6 +1754,6 @@
 
         if state is not None:
-            doc = state.toXML(doc=doc, file=data.filename, entry_node=sasentry,
-                              batch_fit_state=self.batchfit_params)
+            doc = state.to_xml(doc=doc, file=data.filename, entry_node=sasentry,
+                               batch_fit_state=self.batchfit_params)
 
         return doc
