Index: src/sas/perspectives/pr/explore_dialog.py
===================================================================
--- src/sas/perspectives/pr/explore_dialog.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/perspectives/pr/explore_dialog.py	(revision 8b21fa7e884f48449cda4fc02c4ab3b6567f4795)
@@ -3,5 +3,5 @@
 #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. 
+#project funded by the US National Science Foundation.
 #
 #See the license text in license.txt
@@ -16,13 +16,12 @@
 their distribution as a function of D_max.
 """
-    
+
 
 import wx
 import numpy
-import math
 import logging
 import sys
 
-# Avoid Matplotlib complaining about the lack of legend on the plot 
+# Avoid Matplotlib complaining about the lack of legend on the plot
 import warnings
 warnings.simplefilter("ignore")
@@ -46,14 +45,14 @@
     of D_max
     """
-    def __init__(self, d_min, d_max, parent, id = -1, color = None,\
-        dpi = None, style = wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
+    def __init__(self, d_min, d_max, parent, id= -1, color=None, \
+                 dpi=None, style=wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs):
         """
         Initialization. The parameters added to PlotPanel are:
-        
+
         :param d_min: Minimum value of D_max to explore
         :param d_max: Maximum value of D_max to explore
-        
-        """
-        PlotPanel.__init__(self, parent, id = id, style = style, **kwargs)
+
+        """
+        PlotPanel.__init__(self, parent, id=id, style=style, **kwargs)
 
         self.parent = parent
@@ -62,10 +61,10 @@
         self.npts = DEFAULT_NPTS
 
-        step = (self.max-self.min)/(self.npts-1)
-        self.x = numpy.arange(self.min, self.max+step*0.01, step)
+        step = (self.max - self.min) / (self.npts - 1)
+        self.x = numpy.arange(self.min, self.max + step * 0.01, step)
         dx = numpy.zeros(len(self.x))
         y = numpy.ones(len(self.x))
         dy = numpy.zeros(len(self.x))
- 
+
         # Plot area
         self.plot = Model1D(self.x, y=y, dy=dy)
@@ -76,8 +75,8 @@
         self.graph = Graph()
         self.graph.xaxis("\\rm{D_{max}}", 'A')
-        self.graph.yaxis("\\rm{%s}" % DEFAULT_OUTPUT,"")
+        self.graph.yaxis("\\rm{%s}" % DEFAULT_OUTPUT, "")
         self.graph.add(self.plot)
         self.graph.render(self)
-        
+
         self.toolbar.DeleteToolByPos(0)
         self.toolbar.DeleteToolByPos(8)
@@ -87,25 +86,25 @@
         """
         Default context menu for the plot panel
-        
+
         :TODO: Would be nice to add printing and log/linear scales.
-            The current verison of plottools no longer plays well with 
-            plots outside of guiframe. Guiframe team needs to fix this. 
+            The current verison of plottools no longer plays well with
+            plots outside of guiframe. Guiframe team needs to fix this.
         """
         # Slicer plot popup menu
-        id = wx.NewId()
+        wx_id = wx.NewId()
         slicerpop = wx.Menu()
-        slicerpop.Append(id, '&Save image', 'Save image as PNG')
-        wx.EVT_MENU(self, id, self.onSaveImage)
-        
-        id = wx.NewId()
+        slicerpop.Append(wx_id, '&Save image', 'Save image as PNG')
+        wx.EVT_MENU(self, wx_id, self.onSaveImage)
+
+        wx_id = wx.NewId()
         slicerpop.AppendSeparator()
-        slicerpop.Append(id, '&Reset Graph')
-        wx.EVT_MENU(self, id, self.onResetGraph)
-       
+        slicerpop.Append(wx_id, '&Reset Graph')
+        wx.EVT_MENU(self, wx_id, self.onResetGraph)
+
         pos = event.GetPosition()
         pos = self.ScreenToClient(pos)
         self.PopupMenu(slicerpop, pos)
 
-class Results:
+class Results(object):
     """
     Class to hold the inversion output parameters
@@ -126,16 +125,16 @@
         self.bck = []
         self.d_max = []
-        
+
         # Dictionary of outputs
         self.outputs = {}
-        self.outputs['Chi2/dof'] = ["\chi^2/dof", "a.u.", self.chi2]    
-        self.outputs['Oscillation parameter'] = ["Osc", "a.u.", self.osc]    
-        self.outputs['Positive fraction'] = ["P^+", "a.u.", self.pos]    
-        self.outputs['1-sigma positive fraction'] = ["P^+_{1\ \sigma}", 
-                                                     "a.u.", self.pos_err]    
-        self.outputs['Rg'] = ["R_g", "A", self.rg]    
-        self.outputs['I(q=0)'] = ["I(q=0)", "1/A", self.iq0]    
-        self.outputs['Background'] = ["Bck", "1/A", self.bck] 
-        
+        self.outputs['Chi2/dof'] = ["\chi^2/dof", "a.u.", self.chi2]
+        self.outputs['Oscillation parameter'] = ["Osc", "a.u.", self.osc]
+        self.outputs['Positive fraction'] = ["P^+", "a.u.", self.pos]
+        self.outputs['1-sigma positive fraction'] = ["P^+_{1\ \sigma}",
+                                                     "a.u.", self.pos_err]
+        self.outputs['Rg'] = ["R_g", "A", self.rg]
+        self.outputs['I(q=0)'] = ["I(q=0)", "1/A", self.iq0]
+        self.outputs['Background'] = ["Bck", "1/A", self.bck]
+
 class ExploreDialog(wx.Dialog):
     """
@@ -143,33 +142,33 @@
     invoked by the InversionControl class.
     """
-    
+
     def __init__(self, pr_state, nfunc, *args, **kwds):
         """
         Initialization. The parameters added to Dialog are:
-        
+
         :param pr_state: sas.pr.invertor.Invertor object
         :param nfunc: Number of terms in the expansion
-        
-        """
-        kwds["style"] = wx.RESIZE_BORDER|wx.DEFAULT_DIALOG_STYLE
+
+        """
+        kwds["style"] = wx.RESIZE_BORDER | wx.DEFAULT_DIALOG_STYLE
         wx.Dialog.__init__(self, *args, **kwds)
-        
+
         # Initialize Results object
         self.results = Results()
-        
-        self.pr_state  = pr_state
-        self._default_min = 0.9*self.pr_state.d_max
-        self._default_max = 1.1*self.pr_state.d_max
-        self.nfunc     = nfunc
-        
+
+        self.pr_state = pr_state
+        self._default_min = 0.9 * self.pr_state.d_max
+        self._default_max = 1.1 * self.pr_state.d_max
+        self.nfunc = nfunc
+
         # Control for number of points
         self.npts_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER,
-                                   size=(60,20))
+                                   size=(60, 20))
         # Control for the minimum value of D_max
         self.dmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER,
-                                   size=(60,20))
+                                   size=(60, 20))
         # Control for the maximum value of D_max
         self.dmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER,
-                                   size=(60,20))
+                                   size=(60, 20))
 
         # Output selection box for the y axis
@@ -179,39 +178,39 @@
         self.plotpanel = OutputPlot(self._default_min, self._default_max,
                                     self, -1, style=wx.RAISED_BORDER)
-        
+
         # Create the layout of the dialog
         self.__do_layout()
         self.Fit()
-        
+
         # Calculate exploration results
         self._recalc()
         # Graph the default output curve
         self._plot_output()
-        
-    class Event:
+
+    class Event(object):
         """
         Class that holds the content of the form
         """
         ## Number of points to be plotted
-        npts   = 0
+        npts = 0
         ## Minimum value of D_max
-        dmin   = 0
+        dmin = 0
         ## Maximum value of D_max
-        dmax   = 0
-                
+        dmax = 0
+
     def _get_values(self, event=None):
         """
         Invoked when the user changes a value of the form.
         Check that the values are of the right type.
-        
-        :return: ExploreDialog.Event object if the content is good, 
+
+        :return: ExploreDialog.Event object if the content is good,
             None otherwise
         """
         # Flag to make sure that all values are good
         flag = True
-        
+
         # Empty ExploreDialog.Event content
         content_event = self.Event()
-        
+
         # Read each text control and make sure the type is valid
         # Let the user know if a type is invalid by changing the
@@ -225,5 +224,5 @@
             self.npts_ctl.SetBackgroundColour("pink")
             self.npts_ctl.Refresh()
-            
+
         try:
             content_event.dmin = float(self.dmin_ctl.GetValue())
@@ -234,5 +233,5 @@
             self.dmin_ctl.SetBackgroundColour("pink")
             self.dmin_ctl.Refresh()
-        
+
         try:
             content_event.dmax = float(self.dmax_ctl.GetValue())
@@ -243,5 +242,5 @@
             self.dmax_ctl.SetBackgroundColour("pink")
             self.dmax_ctl.Refresh()
-        
+
         # If the content of the form is valid, return the content,
         # otherwise return None
@@ -252,18 +251,18 @@
         else:
             return None
-    
+
     def _plot_output(self, event=None):
         """
-        Invoked when a new output type is selected for plotting, 
+        Invoked when a new output type is selected for plotting,
         or when a new computation is finished.
         """
         # Get the output type selection
         output_type = self.output_box.GetString(self.output_box.GetSelection())
-        
+
         # If the selected output type is part of the results ojbect,
-        # display the results. 
+        # display the results.
         # Note: by design, the output type should always be part of the
         #       results object.
-        if self.results.outputs.has_key(output_type): 
+        if self.results.outputs.has_key(output_type):
             self.plotpanel.plot.x = self.results.d_max
             self.plotpanel.plot.y = self.results.outputs[output_type][2]
@@ -272,10 +271,10 @@
             self.plotpanel.graph.yaxis(y_label,
                                        self.results.outputs[output_type][1])
-            
+
             # Redraw
             self.plotpanel.graph.render(self.plotpanel)
             self.plotpanel.subplot.figure.canvas.draw_idle()
         else:
-            msg =  "ExploreDialog: the Results object's dictionary "
+            msg = "ExploreDialog: the Results object's dictionary "
             msg += "does not contain "
             msg += "the [%s] output type. This must be indicative of "
@@ -283,5 +282,5 @@
             msg += "ExploreDialog code."
             logging.error(msg)
-        
+
     def __do_layout(self):
         """
@@ -291,5 +290,5 @@
         self.SetTitle("D_max Explorer")
         self.SetSize((600, 595))
-        
+
         sizer_main = wx.BoxSizer(wx.VERTICAL)
         sizer_button = wx.BoxSizer(wx.HORIZONTAL)
@@ -298,30 +297,30 @@
         iy = 0
         ix = 0
-        label_npts  = wx.StaticText(self, -1, "Npts")
-        sizer_params.Add(label_npts, (iy, ix), (1, 1), 
-                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+        label_npts = wx.StaticText(self, -1, "Npts")
+        sizer_params.Add(label_npts, (iy, ix), (1, 1),
+                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         ix += 1
-        sizer_params.Add(self.npts_ctl,   (iy, ix), (1, 1), 
-                         wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        sizer_params.Add(self.npts_ctl, (iy, ix), (1, 1),
+                         wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         self.npts_ctl.SetValue("%g" % DEFAULT_NPTS)
         self.npts_ctl.Bind(wx.EVT_KILL_FOCUS, self._recalc)
-        
+
         ix += 1
-        label_dmin   = wx.StaticText(self, -1, "Min Distance [A]")
+        label_dmin = wx.StaticText(self, -1, "Min Distance [A]")
         sizer_params.Add(label_dmin, (iy, ix), (1, 1),
-                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         ix += 1
         sizer_params.Add(self.dmin_ctl, (iy, ix), (1, 1),
-                         wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+                         wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         self.dmin_ctl.SetValue(str(self._default_min))
         self.dmin_ctl.Bind(wx.EVT_KILL_FOCUS, self._recalc)
-        
+
         ix += 1
         label_dmax = wx.StaticText(self, -1, "Max Distance [A]")
         sizer_params.Add(label_dmax, (iy, ix), (1, 1),
-                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         ix += 1
-        sizer_params.Add(self.dmax_ctl,   (iy, ix), (1, 1),
-                         wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        sizer_params.Add(self.dmax_ctl, (iy, ix), (1, 1),
+                         wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         self.dmax_ctl.SetValue(str(self._default_max))
         self.dmax_ctl.Bind(wx.EVT_KILL_FOCUS, self._recalc)
@@ -334,32 +333,32 @@
             self.output_box.Append(item, "")
         self.output_box.SetStringSelection(DEFAULT_OUTPUT)
-        
+
         output_sizer = wx.GridBagSizer(5, 5)
         output_sizer.Add(selection_msg, (0, 0), (1, 1),
-                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10)
+                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10)
         output_sizer.Add(self.output_box, (0, 1), (1, 2),
-                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10)
-        
-        wx.EVT_COMBOBOX(self.output_box, -1, self._plot_output) 
+                         wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10)
+
+        wx.EVT_COMBOBOX(self.output_box, -1, self._plot_output)
         sizer_main.Add(output_sizer, 0, wx.EXPAND | wx.ALL, 10)
-        
+
         sizer_main.Add(self.plotpanel, 0, wx.EXPAND | wx.ALL, 10)
         sizer_main.SetItemMinSize(self.plotpanel, 400, 400)
-        
-        sizer_main.Add(sizer_params, 0, wx.EXPAND|wx.ALL, 10)
+
+        sizer_main.Add(sizer_params, 0, wx.EXPAND | wx.ALL, 10)
         static_line_3 = wx.StaticLine(self, -1)
         sizer_main.Add(static_line_3, 0, wx.EXPAND, 0)
-        
+
         # Bottom area with the close button
-        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         button_OK = wx.Button(self, wx.ID_OK, "Close")
-        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
-        
-        sizer_main.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
+        sizer_button.Add(button_OK, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
+
+        sizer_main.Add(sizer_button, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 10)
         self.SetAutoLayout(True)
         self.SetSizer(sizer_main)
         self.Layout()
         self.Centre()
-        
+
         # Bind the Enter key to recalculation
         self.Bind(wx.EVT_TEXT_ENTER, self._recalc)
@@ -370,5 +369,5 @@
         """
         pass
-    
+
     def _recalc(self, event=None):
         """
@@ -381,17 +380,17 @@
         if content is None:
             return
-        
+
         # Results object to store the computation outputs.
         results = Results()
-        
+
         # Loop over d_max values
-        for i in range(content.npts): 
-            temp = (content.dmax - content.dmin)/(content.npts - 1.0)   
+        for i in range(content.npts):
+            temp = (content.dmax - content.dmin) / (content.npts - 1.0)
             d = content.dmin + i * temp
-                
+
             self.pr_state.d_max = d
             try:
-                out, cov = self.pr_state.invert(self.nfunc)   
-            
+                out, cov = self.pr_state.invert(self.nfunc)
+
                 # Store results
                 iq0 = self.pr_state.iq0(out)
@@ -400,5 +399,5 @@
                 pos_err = self.pr_state.get_pos_err(out, cov)
                 osc = self.pr_state.oscillations(out)
-            
+
                 results.d_max.append(self.pr_state.d_max)
                 results.bck.append(self.pr_state.background)
@@ -408,5 +407,5 @@
                 results.pos.append(pos)
                 results.pos_err.append(pos_err)
-                results.osc.append(osc)           
+                results.osc.append(osc)
             except:
                 # This inversion failed, skip this D_max value
@@ -414,62 +413,7 @@
                 msg += "for D_max=%s\n%s" % (str(d), sys.exc_value)
                 logging.error(msg)
-            
-        self.results = results            
-         
+
+        self.results = results
+
         # Plot the selected output
-        self._plot_output()   
-            
-##### testing code ############################################################
-"""
-Example: ::
-
-class MyApp(wx.App):
-    
-    #Test application used to invoke the ExploreDialog for testing
-   
-    def OnInit(self):
-        from inversion_state import Reader
-        from sas.pr.invertor import Invertor
-        wx.InitAllImageHandlers()
-        
-        def call_back(state, datainfo=None):
-            
-            #Dummy call-back method used by the P(r) 
-            #file reader.
-            
-            print state
-            
-        # Load test data
-        # This would normally be loaded by the application 
-        # of the P(r) plug-in.
-        r = Reader(call_back)
-        data = r.read("test_pr_data.prv")
-        pr_state = data.meta_data['prstate']
-        
-        # Create Invertor object for the data
-        # This would normally be assembled by the P(r) plug-in
-        pr = Invertor()
-        pr.d_max = pr_state.d_max
-        pr.alpha = pr_state.alpha
-        pr.q_min = pr_state.qmin
-        pr.q_max = pr_state.qmax
-        pr.x = data.x
-        pr.y = data.y
-        pr.err = data.y*0.1
-        pr.has_bck = False
-        pr.slit_height = pr_state.height
-        pr.slit_width = pr_state.width
-        
-        # Create the dialog
-        dialog = ExploreDialog(pr, 10, None, -1, "")
-        self.SetTopWindow(dialog)
-        dialog.ShowModal()
-        dialog.Destroy()
-
-        return 1
-
-if __name__ == "__main__":
-    app = MyApp(0)
-    app.MainLoop()
-    
-""" 
+        self._plot_output()
Index: src/sas/perspectives/pr/inversion_panel.py
===================================================================
--- src/sas/perspectives/pr/inversion_panel.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/perspectives/pr/inversion_panel.py	(revision 8b21fa7e884f48449cda4fc02c4ab3b6567f4795)
@@ -10,6 +10,6 @@
 import logging
 from wx.lib.scrolledpanel import ScrolledPanel
-from sas.guiframe.events import StatusEvent   
-from sas.guiframe.panel_base import PanelBase 
+from sas.guiframe.events import StatusEvent
+from sas.guiframe.panel_base import PanelBase
 from inversion_state import InversionState
 from pr_widgets import PrTextCtrl
@@ -28,12 +28,11 @@
     window_caption = "P(r) control panel"
     CENTER_PANE = True
-    
+
     # Figure of merit parameters [default]
-    
+
     ## Oscillation parameters (sin function = 1.1)
     oscillation_max = 1.5
-    
-    def __init__(self, parent, id=-1, plots=None, 
-                 standalone=False, **kwargs):
+
+    def __init__(self, parent, id=-1, plots=None, standalone=False, **kwargs):
         """
         """
@@ -41,39 +40,39 @@
         PanelBase.__init__(self, parent)
         self.SetupScrolling()
-        #Set window's font size 
+        #Set window's font size
         self.SetWindowVariant(variant=FONT_VARIANT)
-        
+
         self.plots = plots
         self.radio_buttons = {}
         self.parent = parent.parent
-        
+
         ## Data file TextCtrl
-        self.data_file  = None
-        self.plot_data  = None
-        self.nfunc_ctl  = None
-        self.alpha_ctl  = None
-        self.dmax_ctl   = None
-        self.time_ctl   = None
-        self.chi2_ctl   = None
-        self.osc_ctl    = None
+        self.data_file = None
+        self.plot_data = None
+        self.nfunc_ctl = None
+        self.alpha_ctl = None
+        self.dmax_ctl = None
+        self.time_ctl = None
+        self.chi2_ctl = None
+        self.osc_ctl = None
         self.file_radio = None
         self.plot_radio = None
         self.label_sugg = None
-        self.qmin_ctl   = None
-        self.qmax_ctl   = None
+        self.qmin_ctl = None
+        self.qmax_ctl = None
         self.swidth_ctl = None
         self.sheight_ctl = None
-        
-        self.rg_ctl     = None
-        self.iq0_ctl    = None
-        self.bck_chk    = None
-        self.bck_ctl    = None
-        
+
+        self.rg_ctl = None
+        self.iq0_ctl = None
+        self.bck_chk = None
+        self.bck_ctl = None
+
         # TextCtrl for fraction of positive P(r)
         self.pos_ctl = None
-        
+
         # TextCtrl for fraction of 1 sigma positive P(r)
-        self.pos_err_ctl = None 
-        
+        self.pos_err_ctl = None
+
         ## Estimates
         self.alpha_estimate_ctl = None
@@ -82,5 +81,5 @@
         self.distance_explorator_ctl = None
         ## Data manager
-        self._manager   = None
+        self._manager = None
         ## Standalone flage
         self.standalone = standalone
@@ -88,11 +87,11 @@
         self._default_save_location = os.getcwd()
         if self.parent is not None:
-            self._default_save_location =\
+            self._default_save_location = \
                         self.parent._default_save_location
-        
+
         # Default width
         self._default_width = 350
         self._do_layout()
-        
+
     def __setattr__(self, name, value):
         """
@@ -115,5 +114,5 @@
         elif name == 'elapsed':
             self.time_ctl.SetValue("%-5.2g" % value)
-        elif name =='rg':
+        elif name == 'rg':
             self.rg_ctl.SetValue("%-5.2g" % value)
         elif name == 'iq0':
@@ -147,5 +146,5 @@
         else:
             wx.Panel.__setattr__(self, name, value)
-        
+
     def __getattr__(self, name):
         """
@@ -182,5 +181,5 @@
             except:
                 return 0.0
-        elif name=='q_max':
+        elif name == 'q_max':
             try:
                 return float(self.qmax_ctl.GetValue())
@@ -197,5 +196,5 @@
             except:
                 return None
-        elif name=='iq0':
+        elif name == 'iq0':
             try:
                 return float(self.iq0_ctl.GetValue())
@@ -212,5 +211,5 @@
             except:
                 return None
-        elif name=='slit_height':
+        elif name == 'slit_height':
             try:
                 return float(self.sheight_ctl.GetValue())
@@ -243,5 +242,5 @@
         else:
             return wx.Panel.__getattribute__(self, name)
-        
+
     def save_project(self, doc=None):
         """
@@ -260,19 +259,18 @@
                 else:
                     doc = new_doc
-        return doc   
-    
+        return doc
+
     def on_save(self, evt=None):
         """
         Method used to create a memento of the current state
-            
-        :return: state object 
+
+        :return: state object
         """
         # Ask the user the location of the file to write to.
         path = None
         if self.parent != None:
-            self._default_save_location =\
-             self.parent._default_save_location
+            self._default_save_location = self.parent._default_save_location
         dlg = wx.FileDialog(self, "Choose a file",
-                            self._default_save_location,\
+                            self._default_save_location,
                             self.window_caption, "*.prv", wx.SAVE)
         if dlg.ShowModal() == wx.ID_OK:
@@ -280,13 +278,12 @@
             self._default_save_location = os.path.dirname(path)
             if self.parent != None:
-                self.parent._default_save_location =\
-                self._default_save_location
+                self.parent._default_save_location = self._default_save_location
         else:
             return None
-        
+
         dlg.Destroy()
-        
+
         state = self.get_state()
-        
+
         # MAC always needs the extension for saving
         extens = ".prv"
@@ -294,62 +291,62 @@
         fName = os.path.splitext(path)[0] + extens
         self._manager.save_data(filepath=fName, prstate=state)
-        
+
         return state
-    
+
     def get_data(self):
         """
         """
         return self._manager.get_data()
-    
+
     def get_state(self):
         """
         Get the current state
-        
+
         : return: state object
         """
-        # Construct the state object    
+        # Construct the state object
         state = InversionState()
-        
+
         # Read the panel's parameters
         flag, alpha, dmax, nfunc, qmin, \
         qmax, height, width = self._read_pars()
-        
+
         state.nfunc = nfunc
         state.d_max = dmax
         state.alpha = alpha
-        state.qmin  = qmin
-        state.qmax  = qmax
+        state.qmin = qmin
+        state.qmax = qmax
         state.width = width
         state.height = height
-        
+
         # Data file
         state.file = self.plot_data.GetValue()
-        
+
         # Background evaluation checkbox
         state.estimate_bck = self.bck_chk.IsChecked()
-        
+
         # Estimates
         state.nterms_estimate = self.nterms_estimate
         state.alpha_estimate = self.alpha_estimate
-        
+
         # Read the output values
-        state.chi2    = self.chi2
+        state.chi2 = self.chi2
         state.elapsed = self.elapsed
-        state.osc     = self.oscillation
-        state.pos     = self.pos
+        state.osc = self.oscillation
+        state.pos = self.pos
         state.pos_err = self.pos_err
-        state.rg      = self.rg
-        state.iq0     = self.iq0
-        state.bck     = self.bck
-        
+        state.rg = self.rg
+        state.iq0 = self.iq0
+        state.bck = self.bck
+
         return state
-    
+
     def set_state(self, state):
         """
         Set the state of the panel and inversion problem to
         the state passed as a parameter.
-        Execute the inversion immediately after filling the 
+        Execute the inversion immediately after filling the
         controls.
-        
+
         :param state: InversionState object
         """
@@ -361,28 +358,28 @@
             self.alpha = state.alpha
         if state.qmin is not None:
-            self.q_min  = state.qmin
+            self.q_min = state.qmin
         if state.qmax is not None:
-            self.q_max  = state.qmax
+            self.q_max = state.qmax
         if state.width is not None:
             self.slit_width = state.width
         if state.height is not None:
             self.slit_height = state.height
-        
+
         # Data file
         self.plot_data.SetValue(str(state.file))
-    
+
         # Background evaluation checkbox
         self.bck_chk.SetValue(state.estimate_bck)
-        
+
         # Estimates
         if state.nterms_estimate is not None:
             self.nterms_estimate = state.nterms_estimate
-        if state.alpha_estimate is not None: 
-            self.alpha_estimate = state.alpha_estimate 
-    
-        
+        if state.alpha_estimate is not None:
+            self.alpha_estimate = state.alpha_estimate
+
+
         # Read the output values
         if state.chi2 is not None:
-            self.chi2    = state.chi2
+            self.chi2 = state.chi2
         if state.elapsed is not None:
             self.elapsed = state.elapsed
@@ -394,23 +391,23 @@
             self.pos_err = state.pos_err
         if state.rg is not None:
-            self.rg      = state.rg
+            self.rg = state.rg
         if state.iq0 is not None:
-            self.iq0     = state.iq0
+            self.iq0 = state.iq0
         if state.bck is not None:
-            self.bck     = state.bck
+            self.bck = state.bck
 
         # Perform inversion
-        self._on_invert(None)    
-        
+        self._on_invert(None)
+
     def set_manager(self, manager):
         self._manager = manager
-        
+
     def _do_layout(self):
-        vbox = wx.GridBagSizer(0,0)
+        vbox = wx.GridBagSizer(0, 0)
         iy_vb = 0
 
         # ----- I(q) data -----
         databox = wx.StaticBox(self, -1, "I(q) data source")
-        
+
         boxsizer1 = wx.StaticBoxSizer(databox, wx.VERTICAL)
         boxsizer1.SetMinSize((self._default_width, 50))
@@ -420,11 +417,11 @@
         self.file_radio = wx.StaticText(self, -1, "Name:")
         pars_sizer.Add(self.file_radio, (iy, 0), (1, 1),
-                       wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        
-        self.plot_data = DataFileTextCtrl(self, -1, size=(260,20))
-        
+                       wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+
+        self.plot_data = DataFileTextCtrl(self, -1, size=(260, 20))
+
         pars_sizer.Add(self.plot_data, (iy, 1), (1, 1),
-                       wx.EXPAND|wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 15)
-        
+                       wx.EXPAND | wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 15)
+
         self.bck_chk = wx.CheckBox(self, -1, "Estimate background level")
         hint_msg = "Check box to let the fit estimate "
@@ -434,9 +431,9 @@
         iy += 1
         pars_sizer.Add(self.bck_chk, (iy, 0), (1, 2),
-                       wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
-        boxsizer1.Add(pars_sizer, 0, wx.EXPAND)  
+                       wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
+        boxsizer1.Add(pars_sizer, 0, wx.EXPAND)
         vbox.Add(boxsizer1, (iy_vb, 0), (1, 1),
-                 wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE|wx.TOP, 5)
-        
+                 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE | wx.TOP, 5)
+
         # ----- Add slit parameters -----
         if True:
@@ -444,56 +441,41 @@
             sboxsizer = wx.StaticBoxSizer(sbox, wx.VERTICAL)
             sboxsizer.SetMinSize((self._default_width, 20))
-            
+
             sizer_slit = wx.GridBagSizer(5, 5)
-    
+
             label_sheight = wx.StaticText(self, -1, "Height", size=(40, 20))
             label_swidth = wx.StaticText(self, -1, "Width", size=(40, 20))
-            #label_sunits1 = wx.StaticText(self, -1, "[A^(-1)]")
-            label_sunits2 = wx.StaticText(self, -1, "[A^(-1)]", size=(55,20))
-            self.sheight_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER,
-                                          size=(60,20))
-            self.swidth_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER,
-                                         size=(60,20))
+            label_sunits2 = wx.StaticText(self, -1, "[A^(-1)]", size=(55, 20))
+            self.sheight_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60, 20))
+            self.swidth_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60, 20))
             hint_msg = "Enter slit height in units of Q or leave blank."
             self.sheight_ctl.SetToolTipString(hint_msg)
             hint_msg = "Enter slit width in units of Q or leave blank."
             self.swidth_ctl.SetToolTipString(hint_msg)
-            #self.sheight_ctl.Bind(wx.EVT_TEXT, self._on_pars_changed)
-            #self.swidth_ctl.Bind(wx.EVT_TEXT,  self._on_pars_changed)
-            
+
             iy = 0
-            sizer_slit.Add(label_sheight,    (iy, 0), (1, 1),
-                           wx.LEFT|wx.EXPAND, 5)
-            sizer_slit.Add(self.sheight_ctl, (iy, 1), (1, 1),
-                           wx.LEFT|wx.EXPAND, 5)
-    
-            sizer_slit.Add(label_swidth,     (iy, 2), (1, 1),
-                           wx.LEFT|wx.EXPAND, 5)
-            sizer_slit.Add(self.swidth_ctl,  (iy, 3), (1, 1),
-                           wx.LEFT|wx.EXPAND, 5)
-            sizer_slit.Add(label_sunits2,    (iy, 4), (1, 1),
-                           wx.LEFT|wx.EXPAND, 5)
-            
+            sizer_slit.Add(label_sheight, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND, 5)
+            sizer_slit.Add(self.sheight_ctl, (iy, 1), (1, 1), wx.LEFT | wx.EXPAND, 5)
+            sizer_slit.Add(label_swidth, (iy, 2), (1, 1), wx.LEFT | wx.EXPAND, 5)
+            sizer_slit.Add(self.swidth_ctl, (iy, 3), (1, 1), wx.LEFT | wx.EXPAND, 5)
+            sizer_slit.Add(label_sunits2, (iy, 4), (1, 1), wx.LEFT | wx.EXPAND, 5)
+
             sboxsizer.Add(sizer_slit, wx.TOP, 15)
             iy_vb += 1
             vbox.Add(sboxsizer, (iy_vb, 0), (1, 1),
-                     wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)
-        
-        
+                     wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 5)
+
         # ----- Q range -----
         qbox = wx.StaticBox(self, -1, "Q range")
         qboxsizer = wx.StaticBoxSizer(qbox, wx.VERTICAL)
         qboxsizer.SetMinSize((self._default_width, 20))
-        
+
         sizer_q = wx.GridBagSizer(5, 5)
 
         label_qmin = wx.StaticText(self, -1, "Q min", size=(40, 20))
         label_qmax = wx.StaticText(self, -1, "Q max", size=(40, 20))
-        #label_qunits1 = wx.StaticText(self, -1, "[A^(-1)]")
         label_qunits2 = wx.StaticText(self, -1, "[A^(-1)]", size=(55, 20))
-        self.qmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER,
-                                   size=(60,20))
-        self.qmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER,
-                                   size=(60,20))
+        self.qmin_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60, 20))
+        self.qmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60, 20))
         hint_msg = "Select a lower bound for Q or leave blank."
         self.qmin_ctl.SetToolTipString(hint_msg)
@@ -502,102 +484,92 @@
         self.qmin_ctl.Bind(wx.EVT_TEXT, self._on_pars_changed)
         self.qmax_ctl.Bind(wx.EVT_TEXT, self._on_pars_changed)
-        
+
         iy = 0
-        sizer_q.Add(label_qmin,    (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 5)
-        sizer_q.Add(self.qmin_ctl, (iy, 1), (1, 1), wx.LEFT|wx.EXPAND, 5)
-        #sizer_q.Add(label_qunits1, (iy,2), (1,1), wx.LEFT|wx.EXPAND, 15)
-        sizer_q.Add(label_qmax,    (iy, 2), (1, 1), wx.LEFT|wx.EXPAND, 5)
-        sizer_q.Add(self.qmax_ctl, (iy, 3), (1, 1), wx.LEFT|wx.EXPAND, 5)
-        sizer_q.Add(label_qunits2, (iy, 4), (1, 1), wx.LEFT|wx.EXPAND, 5)
+        sizer_q.Add(label_qmin, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND, 5)
+        sizer_q.Add(self.qmin_ctl, (iy, 1), (1, 1), wx.LEFT | wx.EXPAND, 5)
+        sizer_q.Add(label_qmax, (iy, 2), (1, 1), wx.LEFT | wx.EXPAND, 5)
+        sizer_q.Add(self.qmax_ctl, (iy, 3), (1, 1), wx.LEFT | wx.EXPAND, 5)
+        sizer_q.Add(label_qunits2, (iy, 4), (1, 1), wx.LEFT | wx.EXPAND, 5)
         qboxsizer.Add(sizer_q, wx.TOP, 15)
 
         iy_vb += 1
-        vbox.Add(qboxsizer, (iy_vb,0), (1,1),
-                 wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)
-    
+        vbox.Add(qboxsizer, (iy_vb, 0), (1, 1),
+                 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 5)
+
         # ----- Parameters -----
         parsbox = wx.StaticBox(self, -1, "Parameters")
         boxsizer2 = wx.StaticBoxSizer(parsbox, wx.VERTICAL)
-        boxsizer2.SetMinSize((self._default_width,50))
-        
-        explanation  = "P(r) is found by fitting a set of base functions"
+        boxsizer2.SetMinSize((self._default_width, 50))
+
+        explanation = "P(r) is found by fitting a set of base functions"
         explanation += " to I(Q). The minimization involves"
         explanation += " a regularization term to ensure a smooth P(r)."
-        explanation += " The regularization constant gives the size of that "  
+        explanation += " The regularization constant gives the size of that "
         explanation += "term. The suggested value is the value above which the"
         explanation += " output P(r) will have only one peak."
-        label_explain = wx.StaticText(self, -1, explanation, size=(280,90))
-        boxsizer2.Add(label_explain,  wx.LEFT|wx.BOTTOM, 5)
-        
-        
-        
+        label_explain = wx.StaticText(self, -1, explanation, size=(280, 90))
+        boxsizer2.Add(label_explain, wx.LEFT | wx.BOTTOM, 5)
+
         label_nfunc = wx.StaticText(self, -1, "Number of terms")
         label_nfunc.SetMinSize((120, 20))
         label_alpha = wx.StaticText(self, -1, "Regularization constant")
-        label_dmax  = wx.StaticText(self, -1, "Max distance [A]")
-        self.label_sugg  = wx.StaticText(self, -1, "Suggested value")
-        #self.label_sugg.Hide()
-        
-        self.nfunc_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER,
-                                    size=(60,20))
+        label_dmax = wx.StaticText(self, -1, "Max distance [A]")
+        self.label_sugg = wx.StaticText(self, -1, "Suggested value")
+
+        self.nfunc_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60, 20))
         self.nfunc_ctl.SetToolTipString("Number of terms in the expansion.")
-        self.alpha_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER,
-                                    size=(60,20))
+        self.alpha_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60, 20))
         hint_msg = "Control parameter for the size of the regularization term."
         self.alpha_ctl.SetToolTipString(hint_msg)
-        self.dmax_ctl  = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER,
-                                    size=(60,20))
+        self.dmax_ctl = PrTextCtrl(self, -1, style=wx.TE_PROCESS_ENTER, size=(60, 20))
         hint_msg = "Maximum distance between any two points in the system."
         self.dmax_ctl.SetToolTipString(hint_msg)
-        id = wx.NewId()
-        self.alpha_estimate_ctl  = wx.Button(self, id, "")
-        #self.alpha_estimate_ctl.Hide()
-        self.Bind(wx.EVT_BUTTON, self._on_accept_alpha, id = id)   
+        wx_id = wx.NewId()
+        self.alpha_estimate_ctl = wx.Button(self, wx_id, "")
+        self.Bind(wx.EVT_BUTTON, self._on_accept_alpha, id=wx_id)
         self.alpha_estimate_ctl.Enable(False)
-        #self.alpha_estimate_ctl.SetBackgroundColour('#ffdf85')
-        #self.alpha_estimate_ctl.SetBackgroundColour(self.GetBackgroundColour())
         self.alpha_estimate_ctl.SetToolTipString("Waiting for estimate...")
-        
-        id = wx.NewId()
-        self.nterms_estimate_ctl  = wx.Button(self, id, "")
+
+        wx_id = wx.NewId()
+        self.nterms_estimate_ctl = wx.Button(self, wx_id, "")
         #self.nterms_estimate_ctl.Hide()
-        self.Bind(wx.EVT_BUTTON, self._on_accept_nterms, id = id)   
+        self.Bind(wx.EVT_BUTTON, self._on_accept_nterms, id=wx_id)
         self.nterms_estimate_ctl.Enable(False)
-      
+
         self.nterms_estimate_ctl.SetToolTipString("Waiting for estimate...")
-        
+
         self.nfunc_ctl.Bind(wx.EVT_TEXT, self._read_pars)
         self.alpha_ctl.Bind(wx.EVT_TEXT, self._read_pars)
         self.dmax_ctl.Bind(wx.EVT_TEXT, self._on_pars_changed)
-        
+
         # Distance explorator
-        id = wx.NewId()
-        self.distance_explorator_ctl = wx.Button(self, id, "Explore")
-        self.Bind(wx.EVT_BUTTON, self._on_explore, id = id)           
-        
-        
-        sizer_params = wx.GridBagSizer(5,5)
+        wx_id = wx.NewId()
+        self.distance_explorator_ctl = wx.Button(self, wx_id, "Explore")
+        self.Bind(wx.EVT_BUTTON, self._on_explore, id=wx_id)
+
+
+        sizer_params = wx.GridBagSizer(5, 5)
 
         iy = 0
         sizer_params.Add(self.label_sugg, (iy, 2), (1, 1), wx.LEFT, 15)
         iy += 1
-        sizer_params.Add(label_nfunc,      (iy, 0), (1, 1), wx.LEFT, 15)
-        sizer_params.Add(self.nfunc_ctl,   (iy, 1), (1, 1), wx.RIGHT, 0)
+        sizer_params.Add(label_nfunc, (iy, 0), (1, 1), wx.LEFT, 15)
+        sizer_params.Add(self.nfunc_ctl, (iy, 1), (1, 1), wx.RIGHT, 0)
         sizer_params.Add(self.nterms_estimate_ctl, (iy, 2), (1, 1), wx.LEFT, 15)
         iy += 1
-        sizer_params.Add(label_alpha,      (iy, 0), (1, 1), wx.LEFT, 15)
-        sizer_params.Add(self.alpha_ctl,   (iy, 1), (1, 1), wx.RIGHT, 0)
+        sizer_params.Add(label_alpha, (iy, 0), (1, 1), wx.LEFT, 15)
+        sizer_params.Add(self.alpha_ctl, (iy, 1), (1, 1), wx.RIGHT, 0)
         sizer_params.Add(self.alpha_estimate_ctl, (iy, 2), (1, 1), wx.LEFT, 15)
         iy += 1
         sizer_params.Add(label_dmax, (iy, 0), (1, 1), wx.LEFT, 15)
-        sizer_params.Add(self.dmax_ctl,   (iy, 1), (1, 1), wx.RIGHT, 0)
+        sizer_params.Add(self.dmax_ctl, (iy, 1), (1, 1), wx.RIGHT, 0)
         sizer_params.Add(self.distance_explorator_ctl, (iy, 2),
                          (1, 1), wx.LEFT, 15)
 
         boxsizer2.Add(sizer_params, 0)
-        
+
         iy_vb += 1
         vbox.Add(boxsizer2, (iy_vb, 0), (1, 1),
-                 wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)
+                 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 5)
 
 
@@ -606,35 +578,35 @@
         ressizer = wx.StaticBoxSizer(resbox, wx.VERTICAL)
         ressizer.SetMinSize((self._default_width, 50))
-        
-        label_rg       = wx.StaticText(self, -1, "Rg")
-        label_rg_unit  = wx.StaticText(self, -1, "[A]")
-        label_iq0      = wx.StaticText(self, -1, "I(Q=0)")
+
+        label_rg = wx.StaticText(self, -1, "Rg")
+        label_rg_unit = wx.StaticText(self, -1, "[A]")
+        label_iq0 = wx.StaticText(self, -1, "I(Q=0)")
         label_iq0_unit = wx.StaticText(self, -1, "[A^(-1)]")
-        label_bck      = wx.StaticText(self, -1, "Background")
+        label_bck = wx.StaticText(self, -1, "Background")
         label_bck_unit = wx.StaticText(self, -1, "[A^(-1)]")
-        self.rg_ctl    = OutputTextCtrl(self, -1, size=(60,20))
+        self.rg_ctl = OutputTextCtrl(self, -1, size=(60, 20))
         hint_msg = "Radius of gyration for the computed P(r)."
         self.rg_ctl.SetToolTipString(hint_msg)
-        self.iq0_ctl   = OutputTextCtrl(self, -1, size=(60, 20))
+        self.iq0_ctl = OutputTextCtrl(self, -1, size=(60, 20))
         hint_msg = "Scattering intensity at Q=0 for the computed P(r)."
         self.iq0_ctl.SetToolTipString(hint_msg)
-        self.bck_ctl   = OutputTextCtrl(self, -1, size=(60, 20))
+        self.bck_ctl = OutputTextCtrl(self, -1, size=(60, 20))
         self.bck_ctl.SetToolTipString("Value of estimated constant background.")
-        
+
         label_time = wx.StaticText(self, -1, "Computation time")
         label_time_unit = wx.StaticText(self, -1, "secs")
-        label_time.SetMinSize((120,20))
+        label_time.SetMinSize((120, 20))
         label_chi2 = wx.StaticText(self, -1, "Chi2/dof")
         label_osc = wx.StaticText(self, -1, "Oscillations")
         label_pos = wx.StaticText(self, -1, "Positive fraction")
         label_pos_err = wx.StaticText(self, -1, "1-sigma positive fraction")
-        
+
         self.time_ctl = OutputTextCtrl(self, -1, size=(60, 20))
         hint_msg = "Computation time for the last inversion, in seconds."
         self.time_ctl.SetToolTipString(hint_msg)
-        
+
         self.chi2_ctl = OutputTextCtrl(self, -1, size=(60, 20))
         self.chi2_ctl.SetToolTipString("Chi^2 over degrees of freedom.")
-        
+
         # Oscillation parameter
         self.osc_ctl = OutputTextCtrl(self, -1, size=(60, 20))
@@ -642,5 +614,5 @@
         hint_msg += " oscillation parameter of 1.1."
         self.osc_ctl.SetToolTipString(hint_msg)
-        
+
         # Positive fraction figure of merit
         self.pos_ctl = OutputTextCtrl(self, -1, size=(60, 20))
@@ -648,8 +620,8 @@
         hint_msg += "Theoretically, P(r) is defined positive."
         self.pos_ctl.SetToolTipString(hint_msg)
-        
+
         # 1-simga positive fraction figure of merit
         self.pos_err_ctl = OutputTextCtrl(self, -1, size=(60, 20))
-        message  = "Fraction of P(r) that is at least 1 standard deviation"
+        message = "Fraction of P(r) that is at least 1 standard deviation"
         message += " greater than zero.\n"
         message += "This figure of merit tells you about the size of the "
@@ -658,93 +630,87 @@
         message += " consider changing the maximum distance."
         self.pos_err_ctl.SetToolTipString(message)
-        
+
         sizer_res = wx.GridBagSizer(5, 5)
 
         iy = 0
-        sizer_res.Add(label_rg, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15)
-        sizer_res.Add(self.rg_ctl,   (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15)
-        sizer_res.Add(label_rg_unit,   (iy, 2), (1, 1), wx.RIGHT|wx.EXPAND, 15)
+        sizer_res.Add(label_rg, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND, 15)
+        sizer_res.Add(self.rg_ctl, (iy, 1), (1, 1), wx.RIGHT | wx.EXPAND, 15)
+        sizer_res.Add(label_rg_unit, (iy, 2), (1, 1), wx.RIGHT | wx.EXPAND, 15)
         iy += 1
-        sizer_res.Add(label_iq0, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15)
-        sizer_res.Add(self.iq0_ctl,   (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15)
-        sizer_res.Add(label_iq0_unit, (iy, 2), (1, 1), wx.RIGHT|wx.EXPAND, 15)
+        sizer_res.Add(label_iq0, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND, 15)
+        sizer_res.Add(self.iq0_ctl, (iy, 1), (1, 1), wx.RIGHT | wx.EXPAND, 15)
+        sizer_res.Add(label_iq0_unit, (iy, 2), (1, 1), wx.RIGHT | wx.EXPAND, 15)
         iy += 1
-        sizer_res.Add(label_bck, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15)
-        sizer_res.Add(self.bck_ctl, (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15)
-        sizer_res.Add(label_bck_unit, (iy, 2), (1, 1), wx.RIGHT|wx.EXPAND, 15)
+        sizer_res.Add(label_bck, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND, 15)
+        sizer_res.Add(self.bck_ctl, (iy, 1), (1, 1), wx.RIGHT | wx.EXPAND, 15)
+        sizer_res.Add(label_bck_unit, (iy, 2), (1, 1), wx.RIGHT | wx.EXPAND, 15)
         iy += 1
-        sizer_res.Add(label_time, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15)
-        sizer_res.Add(self.time_ctl,   (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15)
-        sizer_res.Add(label_time_unit, (iy, 2), (1, 1), wx.RIGHT|wx.EXPAND, 15)
+        sizer_res.Add(label_time, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND, 15)
+        sizer_res.Add(self.time_ctl, (iy, 1), (1, 1), wx.RIGHT | wx.EXPAND, 15)
+        sizer_res.Add(label_time_unit, (iy, 2), (1, 1), wx.RIGHT | wx.EXPAND, 15)
         iy += 1
-        sizer_res.Add(label_chi2, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15)
-        sizer_res.Add(self.chi2_ctl,   (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15)
+        sizer_res.Add(label_chi2, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND, 15)
+        sizer_res.Add(self.chi2_ctl, (iy, 1), (1, 1), wx.RIGHT | wx.EXPAND, 15)
         iy += 1
-        sizer_res.Add(label_osc, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15)
-        sizer_res.Add(self.osc_ctl,   (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15)
+        sizer_res.Add(label_osc, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND, 15)
+        sizer_res.Add(self.osc_ctl, (iy, 1), (1, 1), wx.RIGHT | wx.EXPAND, 15)
 
         iy += 1
-        sizer_res.Add(label_pos, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15)
-        sizer_res.Add(self.pos_ctl, (iy, 1), (1, 1), wx.RIGHT|wx.EXPAND, 15)
+        sizer_res.Add(label_pos, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND, 15)
+        sizer_res.Add(self.pos_ctl, (iy, 1), (1, 1), wx.RIGHT | wx.EXPAND, 15)
 
         iy += 1
-        sizer_res.Add(label_pos_err, (iy, 0), (1, 1), wx.LEFT|wx.EXPAND, 15)
-        sizer_res.Add(self.pos_err_ctl,  (iy,1), (1, 1), wx.RIGHT|wx.EXPAND, 15)
+        sizer_res.Add(label_pos_err, (iy, 0), (1, 1), wx.LEFT | wx.EXPAND, 15)
+        sizer_res.Add(self.pos_err_ctl, (iy, 1), (1, 1), wx.RIGHT | wx.EXPAND, 15)
 
         ressizer.Add(sizer_res, 0)
         iy_vb += 1
         vbox.Add(ressizer, (iy_vb, 0), (1, 1),
-                 wx.LEFT|wx.RIGHT|wx.EXPAND|wx.ADJUST_MINSIZE, 5)
+                 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE, 5)
 
         # ----- Buttons -----
-        id = wx.NewId()
-        button_OK = wx.Button(self, id, "Compute")
-        button_OK.SetToolTipString("Perform P(r) inversion.")
-        self.Bind(wx.EVT_BUTTON, self._on_invert, id = id)   
-        
+        wx_id = wx.NewId()
+        button_ok = wx.Button(self, wx_id, "Compute")
+        button_ok.SetToolTipString("Perform P(r) inversion.")
+        self.Bind(wx.EVT_BUTTON, self._on_invert, id=wx_id)
+
         self._set_reset_flag(True)
         self._set_save_flag(True)
         sizer_button = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_button.Add(button_OK, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10)
-       
+        sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(button_ok, 0, wx.LEFT | wx.ADJUST_MINSIZE, 10)
+
         iy_vb += 1
         vbox.Add(sizer_button, (iy_vb, 0), (1, 1),
-                 wx.EXPAND|wx.BOTTOM|wx.TOP|wx.RIGHT, 10)
+                 wx.EXPAND | wx.BOTTOM | wx.TOP | wx.RIGHT, 10)
 
         self.Bind(wx.EVT_TEXT_ENTER, self._on_invert)
 
         self.SetSizer(vbox)
-        
+
     def _on_accept_alpha(self, evt):
         """
-        User has accepted the estimated alpha, 
+        User has accepted the estimated alpha,
         set it as part of the input parameters
         """
         try:
             alpha = self.alpha_estimate_ctl.GetLabel()
-            tmp = float(alpha)
-            self.alpha_ctl.SetValue(alpha)
+            self.alpha_ctl.SetValue(float(alpha))
         except:
             # No estimate or bad estimate, either do nothing
-            #import sys
-            print "InversionControl._on_accept_alpha: %s" % sys.exc_value
-            pass
-    
+            logging.error("InversionControl._on_accept_alpha: %s" % sys.exc_value)
+
     def _on_accept_nterms(self, evt):
         """
-        User has accepted the estimated number of terms, 
+        User has accepted the estimated number of terms,
         set it as part of the input parameters
         """
         try:
             nterms = self.nterms_estimate_ctl.GetLabel()
-            tmp = float(nterms)
-            self.nfunc_ctl.SetValue(nterms)
+            self.nfunc_ctl.SetValue(float(nterms))
         except:
             # No estimate or bad estimate, either do nothing
-            import sys
-            print "InversionControl._on_accept_nterms: %s" % sys.exc_value
-            pass
-        
+            logging.error("InversionControl._on_accept_nterms: %s" % sys.exc_value)
+
     def clear_panel(self):
         """
@@ -752,5 +718,5 @@
         self.plot_data.SetValue("")
         self.on_reset(event=None)
-        
+
     def on_reset(self, event=None):
         """
@@ -775,38 +741,38 @@
         self.nterms_estimate_ctl.SetLabel("")
         self._on_pars_changed()
-        
+
     def _on_pars_changed(self, evt=None):
         """
         Called when an input parameter has changed
         We will estimate the alpha parameter behind the
-        scenes. 
+        scenes.
         """
         flag, alpha, dmax, nfunc, qmin, qmax, height, width = self._read_pars()
         has_bck = self.bck_chk.IsChecked()
-        
+
         # If the pars are valid, estimate alpha
         if flag:
             self.nterms_estimate_ctl.Enable(False)
             self.alpha_estimate_ctl.Enable(False)
-            
+
             dataset = self.plot_data.GetValue()
             if dataset is not None and dataset.strip() != "":
-                self._manager.estimate_plot_inversion(alpha=alpha, nfunc=nfunc, 
-                                                 d_max=dmax,
-                                                 q_min=qmin, q_max=qmax,
-                                                 bck=has_bck, 
-                                                 height=height,
-                                                 width=width)
-        
+                self._manager.estimate_plot_inversion(alpha=alpha, nfunc=nfunc,
+                                                      d_max=dmax,
+                                                      q_min=qmin, q_max=qmax,
+                                                      bck=has_bck,
+                                                      height=height,
+                                                      width=width)
+
     def _read_pars(self, evt=None):
         """
-        """    
+        """
         alpha = 0
         nfunc = 5
-        dmax  = 120
-        qmin  = 0
-        qmax  = 0
+        dmax = 120
+        qmin = 0
+        qmax = 0
         height = 0
-        width  = 0
+        width = 0
         flag = True
         # Read slit height
@@ -823,9 +789,9 @@
             self.sheight_ctl.SetBackgroundColour("pink")
             self.sheight_ctl.Refresh()
-            
+
         # Read slit width
         try:
             width_str = self.swidth_ctl.GetValue()
-            if len(width_str.lstrip().rstrip())==0:
+            if len(width_str.lstrip().rstrip()) == 0:
                 width = 0
             else:
@@ -837,5 +803,5 @@
             self.swidth_ctl.SetBackgroundColour("pink")
             self.swidth_ctl.Refresh()
-        
+
         # Read alpha
         try:
@@ -847,6 +813,6 @@
             self.alpha_ctl.SetBackgroundColour("pink")
             self.alpha_ctl.Refresh()
-        
-        # Read d_max    
+
+        # Read d_max
         try:
             dmax = float(self.dmax_ctl.GetValue())
@@ -857,5 +823,5 @@
             self.dmax_ctl.SetBackgroundColour("pink")
             self.dmax_ctl.Refresh()
-            
+
         # Read nfunc
         try:
@@ -873,5 +839,5 @@
             self.nfunc_ctl.SetBackgroundColour("pink")
             self.nfunc_ctl.Refresh()
-        
+
         # Read qmin
         try:
@@ -887,5 +853,5 @@
             self.qmin_ctl.SetBackgroundColour("pink")
             self.qmin_ctl.Refresh()
-        
+
         # Read qmax
         try:
@@ -901,7 +867,7 @@
             self.qmax_ctl.SetBackgroundColour("pink")
             self.qmax_ctl.Refresh()
-        
+
         return flag, alpha, dmax, nfunc, qmin, qmax, height, width
-    
+
     def _on_explore(self, evt):
         """
@@ -916,36 +882,36 @@
             message = "No data to analyze. Please load a data set to proceed."
             wx.PostEvent(self._manager.parent, StatusEvent(status=message))
-            
+
     def _on_invert(self, evt):
         """
         Perform inversion
-        
-        :param silent: when True, there will be no output for the user 
-        
+
+        :param silent: when True, there will be no output for the user
+
         """
         # Get the data from the form
         # Push it to the manager
-        
+
         flag, alpha, dmax, nfunc, qmin, qmax, height, width = self._read_pars()
         has_bck = self.bck_chk.IsChecked()
-        
+
         if flag:
             dataset = self.plot_data.GetValue()
-            if dataset==None or len(dataset.strip())==0:
+            if dataset == None or len(dataset.strip()) == 0:
                 message = "No data to invert. Select a data set before"
                 message += " proceeding with P(r) inversion."
                 wx.PostEvent(self._manager.parent, StatusEvent(status=message))
             else:
-                self._manager.setup_plot_inversion(alpha=alpha, nfunc=nfunc, 
-                                                  d_max=dmax,
-                                                  q_min=qmin, q_max=qmax,
-                                                  bck=has_bck,
-                                                  height=height,
-                                                  width=width)
+                self._manager.setup_plot_inversion(alpha=alpha, nfunc=nfunc,
+                                                   d_max=dmax,
+                                                   q_min=qmin, q_max=qmax,
+                                                   bck=has_bck,
+                                                   height=height,
+                                                   width=width)
         else:
             message = "The P(r) form contains invalid values: "
             message += "please submit it again."
             wx.PostEvent(self.parent, StatusEvent(status=message))
-        
+
     def _change_file(self, evt=None, filepath=None, data=None):
         """
@@ -960,5 +926,5 @@
             except:
                 msg = "InversionControl._change_file: %s" % sys.exc_value
-                logging.error(msg)                    
+                logging.error(msg)
 
 class HelpDialog(wx.Dialog):
@@ -970,5 +936,5 @@
         from sas.pr.invertor import help
         wx.Dialog.__init__(self, parent, id, size=(400, 450))
-        self.SetTitle("P(r) help") 
+        self.SetTitle("P(r) help")
         self.SetWindowVariant(variant=FONT_VARIANT)
 
@@ -976,25 +942,24 @@
 
         explanation = help()
-           
+
         label_explain = wx.StaticText(self, -1, explanation, size=(360, 350))
-            
-        vbox.Add(label_explain, 0, wx.ALL|wx.EXPAND, 15)
+
+        vbox.Add(label_explain, 0, wx.ALL | wx.EXPAND, 15)
 
 
         static_line = wx.StaticLine(self, -1)
         vbox.Add(static_line, 0, wx.EXPAND, 0)
-        
-        button_OK = wx.Button(self, wx.ID_OK, "OK")
-        #button_Cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
-        
+
+        button_ok = wx.Button(self, wx.ID_OK, "OK")
+
         sizer_button = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
-        
-        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
+        sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(button_ok, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
+
+        vbox.Add(sizer_button, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 10)
 
         self.SetSizer(vbox)
         self.SetAutoLayout(True)
-        
+
         self.Layout()
         self.Centre()
@@ -1008,36 +973,36 @@
         from sas.pr.invertor import help
         wx.Dialog.__init__(self, parent, id, size=(250, 120))
-        self.SetTitle("P(r) distribution") 
-        
+        self.SetTitle("P(r) distribution")
+
 
         vbox = wx.BoxSizer(wx.VERTICAL)
-        
+
         label_npts = wx.StaticText(self, -1, "Number of points")
         self.npts_ctl = PrTextCtrl(self, -1, size=(100, 20))
-                 
+
         pars_sizer = wx.GridBagSizer(5, 5)
         iy = 0
         pars_sizer.Add(label_npts, (iy, 0), (1, 1), wx.LEFT, 15)
         pars_sizer.Add(self.npts_ctl, (iy, 1), (1, 1), wx.RIGHT, 0)
-        
-        vbox.Add(pars_sizer, 0, wx.ALL|wx.EXPAND, 15)
+
+        vbox.Add(pars_sizer, 0, wx.ALL | wx.EXPAND, 15)
 
         static_line = wx.StaticLine(self, -1)
         vbox.Add(static_line, 0, wx.EXPAND, 0)
-        
-        button_OK = wx.Button(self, wx.ID_OK, "OK")
-        self.Bind(wx.EVT_BUTTON, self._checkValues, button_OK)
-        button_Cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
-        
+
+        button_ok = wx.Button(self, wx.ID_OK, "OK")
+        self.Bind(wx.EVT_BUTTON, self._checkValues, button_ok)
+        button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
+
         sizer_button = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
-        sizer_button.Add(button_OK, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
-        sizer_button.Add(button_Cancel, 0,
-                         wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)        
-        vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10)
+        sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
+        sizer_button.Add(button_ok, 0, wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
+        sizer_button.Add(button_cancel, 0,
+                         wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
+        vbox.Add(sizer_button, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 10)
 
         self.SetSizer(vbox)
         self.SetAutoLayout(True)
-        
+
         self.Layout()
         self.Centre()
@@ -1067,5 +1032,5 @@
         value = int(self.npts_ctl.GetValue())
         return value
-    
+
     def set_content(self, npts):
         """
@@ -1073,29 +1038,2 @@
         """
         self.npts_ctl.SetValue("%i" % npts)
-
-##### testing code ############################################################
-"""
-Example: ::
-
-class TestPlot:
-    def __init__(self, text):
-        self.name = text
-    
-class MyApp(wx.App):
-    def OnInit(self):
-        wx.InitAllImageHandlers()
-        dialog = PrDistDialog(None, -1)
-        if dialog.ShowModal() == wx.ID_OK:
-            pass
-        dialog.Destroy()
-        
-        return 1
-
-# end of class MyApp
-
-if __name__ == "__main__":
-    app = MyApp(0)
-    app.MainLoop()
-    
-"""
-##### end of testing code #####################################################    
Index: src/sas/perspectives/pr/inversion_state.py
===================================================================
--- src/sas/perspectives/pr/inversion_state.py	(revision c4f68511934593a5680c5ee35fede3e78dfa457c)
+++ src/sas/perspectives/pr/inversion_state.py	(revision 8b21fa7e884f48449cda4fc02c4ab3b6567f4795)
@@ -5,5 +5,5 @@
 #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. 
+#project funded by the US National Science Foundation.
 #
 #See the license text in license.txt
@@ -26,25 +26,25 @@
 
 # Translation of names between stored and object data
-## List of P(r) inversion inputs 
-in_list =  [["nterms",       "nfunc"],
-           ["d_max",        "d_max"],
-           ["alpha",        "alpha"],
-           ["slit_width",   "width"],
-           ["slit_height",  "height"],
-           ["qmin",         "qmin"],
-           ["qmax",         "qmax"],
-           ["estimate_bck", "estimate_bck"]]                      
+## List of P(r) inversion inputs
+in_list = [["nterms", "nfunc"],
+           ["d_max", "d_max"],
+           ["alpha", "alpha"],
+           ["slit_width", "width"],
+           ["slit_height", "height"],
+           ["qmin", "qmin"],
+           ["qmax", "qmax"],
+           ["estimate_bck", "estimate_bck"]]
 
 ## List of P(r) inversion outputs
 out_list = [["elapsed", "elapsed"],
-           ["rg",      "rg"],
-           ["iq0",     "iq0"],
-           ["bck",     "bck"],
-           ["chi2",    "chi2"],
-           ["osc",     "osc"],
-           ["pos",     "pos"],
-           ["pos_err", "pos_err"],
-           ["alpha_estimate", "alpha_estimate"],
-           ["nterms_estimate", "nterms_estimate"]]
+            ["rg", "rg"],
+            ["iq0", "iq0"],
+            ["bck", "bck"],
+            ["chi2", "chi2"],
+            ["osc", "osc"],
+            ["pos", "pos"],
+            ["pos_err", "pos_err"],
+            ["alpha_estimate", "alpha_estimate"],
+            ["nterms_estimate", "nterms_estimate"]]
 
 class InversionState(object):
@@ -56,53 +56,53 @@
         Default values
         """
-        # Input 
-        self.file  = None
+        # Input
+        self.file = None
         self.estimate_bck = False
         self.timestamp = time.time()
-        
+
         # Inversion parameters
         self.nfunc = None
         self.d_max = None
         self.alpha = None
-        
+
         # Slit parameters
         self.height = None
-        self.width  = None
-        
+        self.width = None
+
         # Q range
-        self.qmin  = None
-        self.qmax  = None
-        
+        self.qmin = None
+        self.qmax = None
+
         # Outputs
         self.elapsed = None
-        self.rg    = None
-        self.iq0   = None
-        self.bck   = None
-        self.chi2  = None
-        self.osc   = None
-        self.pos   = None
+        self.rg = None
+        self.iq0 = None
+        self.bck = None
+        self.chi2 = None
+        self.osc = None
+        self.pos = None
         self.pos_err = None
-        
+
         # Estimates
         self.alpha_estimate = None
         self.nterms_estimate = None
-        
+
         # Data
-        self.q       = None
-        self.iq_obs  = None
+        self.q = None
+        self.iq_obs = None
         self.iq_calc = None
-        
+
         # Coefficients
         self.coefficients = None
         self.covariance = None
-    
+
     def __str__(self):
         """
         Pretty print
-        
+
         :return: string representing the state
-        
-        """
-        state  = "File:         %s\n" % self.file
+
+        """
+        state = "File:         %s\n" % self.file
         state += "Timestamp:    %s\n" % self.timestamp
         state += "Estimate bck: %s\n" % str(self.estimate_bck)
@@ -110,15 +110,15 @@
         state += "D_max:        %s\n" % str(self.d_max)
         state += "Alpha:        %s\n" % str(self.alpha)
-        
+
         state += "Slit height:  %s\n" % str(self.height)
         state += "Slit width:   %s\n" % str(self.width)
-        
+
         state += "Qmin:         %s\n" % str(self.qmin)
         state += "Qmax:         %s\n" % str(self.qmax)
-        
+
         state += "\nEstimates:\n"
         state += "  Alpha:      %s\n" % str(self.alpha_estimate)
         state += "  Nterms:     %s\n" % str(self.nterms_estimate)
-        
+
         state += "\nOutputs:\n"
         state += "  Elapsed:    %s\n" % str(self.elapsed)
@@ -130,21 +130,21 @@
         state += "  Positive:   %s\n" % str(self.pos)
         state += "  1-sigma pos:%s\n" % str(self.pos_err)
-        
+
         return state
-        
+
     def toXML(self, file="pr_state.prv", doc=None, entry_node=None):
         """
         Writes the state of the InversionControl panel to file, as XML.
-        
+
         Compatible with standalone writing, or appending to an
         already existing XML document. In that case, the XML document
-        is required. An optional entry node in the XML document 
+        is required. An optional entry node in the XML document
         may also be given.
-        
+
         :param file: file to write to
         :param doc: XML document object [optional]
-        :param entry_node: XML node within the XML document at which 
+        :param entry_node: XML node within the XML document at which
             we will append the data [optional]
-        
+
         """
         #TODO: Get this to work
@@ -154,7 +154,7 @@
         if doc is None:
             impl = getDOMImplementation()
-        
-            doc_type = impl.createDocumentType(PRNODE_NAME, "1.0", "1.0")     
-        
+
+            doc_type = impl.createDocumentType(PRNODE_NAME, "1.0", "1.0")
+
             newdoc = impl.createDocument(None, PRNODE_NAME, doc_type)
             top_element = newdoc.documentElement
@@ -167,9 +167,9 @@
             else:
                 entry_node.appendChild(top_element)
-            
+
         attr = newdoc.createAttribute("version")
         attr.nodeValue = '1.0'
         top_element.setAttributeNode(attr)
-        
+
         # File name
         element = newdoc.createElement("filename")
@@ -179,5 +179,5 @@
             element.appendChild(newdoc.createTextNode(str(file)))
         top_element.appendChild(element)
-        
+
         element = newdoc.createElement("timestamp")
         element.appendChild(newdoc.createTextNode(time.ctime(self.timestamp)))
@@ -186,23 +186,23 @@
         element.setAttributeNode(attr)
         top_element.appendChild(element)
-        
+
         # Inputs
         inputs = newdoc.createElement("inputs")
         top_element.appendChild(inputs)
-        
+
         for item in in_list:
             element = newdoc.createElement(item[0])
             element.appendChild(newdoc.createTextNode(str(getattr(self, item[1]))))
             inputs.appendChild(element)
-              
+
         # Outputs
         outputs = newdoc.createElement("outputs")
         top_element.appendChild(outputs)
-        
+
         for item in out_list:
             element = newdoc.createElement(item[0])
             element.appendChild(newdoc.createTextNode(str(getattr(self, item[1]))))
             outputs.appendChild(element)
-                    
+
         # Save output coefficients and its covariance matrix
         element = newdoc.createElement("coefficients")
@@ -212,5 +212,5 @@
         element.appendChild(newdoc.createTextNode(str(self.covariance)))
         outputs.appendChild(element)
-                    
+
         # Save the file
         if doc is None:
@@ -225,8 +225,8 @@
         """
         Load a P(r) inversion state from a file
-        
+
         :param file: .prv file
         :param node: node of a XML document to read from
-        
+
         """
         if file is not None:
@@ -234,12 +234,12 @@
             msg += " format for P(r) files"
             raise RuntimeError, msg
-            
+
         if node.get('version') and node.get('version') == '1.0':
-            
+
             # Get file name
             entry = get_content('ns:filename', node)
             if entry is not None:
                 self.file = entry.text.strip()
-            
+
             # Get time stamp
             entry = get_content('ns:timestamp', node)
@@ -251,5 +251,5 @@
                     msg += "timestamp\n %s" % sys.exc_value
                     logging.error(msg)
-            
+
             # Parse inversion inputs
             entry = get_content('ns:inputs', node)
@@ -265,8 +265,8 @@
                 if input_field is not None:
                     try:
-                        self.estimate_bck = input_field.text.strip()=='True'
+                        self.estimate_bck = input_field.text.strip() == 'True'
                     except:
                         self.estimate_bck = False
-                    
+
             # Parse inversion outputs
             entry = get_content('ns:outputs', node)
@@ -280,5 +280,5 @@
                         except:
                             setattr(self, item[1], None)
-            
+
                 # Look for coefficients
                 # Format is [value, value, value, value]
@@ -286,6 +286,6 @@
                 if coeff is not None:
                     # Remove brackets
-                    c_values = coeff.text.strip().replace('[','')
-                    c_values = c_values.replace(']','')
+                    c_values = coeff.text.strip().replace('[', '')
+                    c_values = c_values.replace(']', '')
                     toks = c_values.split()
                     self.coefficients = []
@@ -308,5 +308,5 @@
                         logging.error(err_msg)
                         self.coefficients = None
-                
+
                 # Look for covariance matrix
                 # Format is [ [value, value], [value, value] ]
@@ -320,5 +320,5 @@
                         if len(row) == 0: continue
                         # Remove end bracket
-                        row = row.replace(']','')
+                        row = row.replace(']', '')
                         c_values = row.split()
                         cov_row = []
@@ -345,5 +345,5 @@
                         logging.error(err_msg)
                         self.covariance = None
-    
+
 class Reader(CansasReader):
     """
@@ -352,20 +352,20 @@
     ## File type
     type_name = "P(r)"
-    
+
     ## Wildcards
     type = ["P(r) files (*.prv)|*.prv",
             "SASView files (*.svs)|*.svs"]
     ## List of allowed extensions
-    ext = ['.prv', '.PRV', '.svs', '.SVS']  
-    
+    ext = ['.prv', '.PRV', '.svs', '.SVS']
+
     def __init__(self, call_back, cansas=True):
         """
         Initialize the call-back method to be called
         after we load a file
-        
+
         :param call_back: call-back method
         :param cansas:  True = files will be written/read in CanSAS format
                         False = write CanSAS format
-            
+
         """
         ## Call back method to be executed after a file is read
@@ -374,56 +374,56 @@
         self.cansas = cansas
         self.state = None
-        
+
     def read(self, path):
-        """ 
+        """
         Load a new P(r) inversion state from file
-        
+
         :param path: file path
-        
+
         :return: None
-        
-        """
-        if self.cansas==True:
+
+        """
+        if self.cansas == True:
             return self._read_cansas(path)
         else:
             return self._read_standalone(path)
-        
+
     def _read_standalone(self, path):
-        """ 
+        """
         Load a new P(r) inversion state from file.
         The P(r) node is assumed to be the top element.
-        
+
         :param path: file path
-        
+
         :return: None
-        
+
         """
         # Read the new state from file
         state = InversionState()
         state.fromXML(file=path)
-        
+
         # Call back to post the new state
         self.state = state
         #self.call_back(state)
         return None
-    
+
     def _parse_prstate(self, entry):
         """
         Read a p(r) inversion result from an XML node
-        
-        :param entry: XML node to read from 
-        
+
+        :param entry: XML node to read from
+
         :return: InversionState object
-        
+
         """
         state = None
-        
+
         # Locate the P(r) node
         try:
             nodes = entry.xpath('ns:%s' % PRNODE_NAME,
                                 namespaces={'ns': CANSAS_NS})
-            if nodes !=[]:
+            if nodes != []:
                 # Create an empty state
-                state =  InversionState()
+                state = InversionState()
                 state.fromXML(node=nodes[0])
         except:
@@ -431,30 +431,30 @@
             msg += "information.\n %s" % sys.exc_value
             logging.info(msg)
-            
+
         return state
-    
+
     def _read_cansas(self, path):
-        """ 
+        """
         Load data and P(r) information from a CanSAS XML file.
-        
+
         :param path: file path
-        
-        :return: Data1D object if a single SASentry was found, 
+
+        :return: Data1D object if a single SASentry was found,
                     or a list of Data1D objects if multiple entries were found,
                     or None of nothing was found
-                    
+
         :raise RuntimeError: when the file can't be opened
         :raise ValueError: when the length of the data vectors are inconsistent
-        
+
         """
         output = []
-        
+
         if os.path.isfile(path):
-            basename  = os.path.basename(path)
+            basename = os.path.basename(path)
             root, extension = os.path.splitext(basename)
             #TODO: eventually remove the check for .xml once
             # the P(r) writer/reader is truly complete.
             if  extension.lower() in self.ext or extension.lower() == '.xml':
-                
+
                 tree = etree.parse(path, parser=etree.ETCompatXMLParser())
                 # Check the format version number
@@ -462,5 +462,5 @@
                 #format version 
                 root = tree.getroot()
-                
+
                 entry_list = root.xpath('/ns:SASroot/ns:SASentry',
                                         namespaces={'ns': CANSAS_NS})
@@ -477,5 +477,5 @@
         else:
             raise RuntimeError, "%s is not a file" % path
-        
+
         # Return output consistent with the loader's api
         if len(output) == 0:
@@ -483,23 +483,23 @@
         elif len(output) == 1:
             # Call back to post the new state
-            self.call_back(output[0].meta_data['prstate'], datainfo = output[0])
+            self.call_back(output[0].meta_data['prstate'], datainfo=output[0])
             #self.state = output[0].meta_data['prstate']
             return output[0]
         else:
-            return output                
-    
-    
+            return output
+
+
     def write(self, filename, datainfo=None, prstate=None):
         """
         Write the content of a Data1D as a CanSAS XML file
-        
+
         :param filename: name of the file to write
         :param datainfo: Data1D object
         :param prstate: InversionState object
-        
+
         """
         # Sanity check
         if self.cansas == True:
-            doc = self.write_toXML(datainfo, prstate)        
+            doc = self.write_toXML(datainfo, prstate)
             # Write the XML document
             fd = open(filename, 'w')
@@ -508,25 +508,24 @@
         else:
             prstate.toXML(file=filename)
-        
+
     def write_toXML(self, datainfo=None, state=None):
         """
         Write toXML, a helper for write()
-        
+
         : return: xml doc
         """
         if datainfo is None:
-            datainfo = Data1D(x=[], y=[])    
+            datainfo = Data1D(x=[], y=[])
         elif not issubclass(datainfo.__class__, Data1D):
             msg = "The cansas writer expects a Data1D "
             msg += "instance: %s" % str(datainfo.__class__.__name__)
             raise RuntimeError, msg
-    
+
         # Create basic XML document
         doc, sasentry = self._to_xml_doc(datainfo)
-        
+
         # Add the invariant information to the XML document
         if state is not None:
             doc = state.toXML(doc=doc, entry_node=sasentry)
-            
-        return doc 
-    
+
+        return doc
Index: src/sas/perspectives/pr/pr_thread.py
===================================================================
--- src/sas/perspectives/pr/pr_thread.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/perspectives/pr/pr_thread.py	(revision 8b21fa7e884f48449cda4fc02c4ab3b6567f4795)
@@ -3,5 +3,5 @@
 #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. 
+#project funded by the US National Science Foundation.
 #
 #See the license text in license.txt
@@ -18,22 +18,15 @@
     Compute P(r)
     """
-    
-    def __init__(self, pr, nfunc=5, error_func=None,
-                 completefn = None,
-                 updatefn   = None,
-                 yieldtime  = 0.01,
-                 worktime   = 0.01
-                 ):
+
+    def __init__(self, pr, nfunc=5, error_func=None, completefn=None,
+                 updatefn=None, yieldtime=0.01, worktime=0.01):
         """
         """
-        CalcThread.__init__(self,completefn,
-                 updatefn,
-                 yieldtime,
-                 worktime)
+        CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime)
         self.pr = pr
         self.nfunc = nfunc
         self.error_func = error_func
         self.starttime = 0
-        
+
     def compute(self):
         """
@@ -43,7 +36,5 @@
             self.starttime = time.time()
             out, cov = self.pr.invert(self.nfunc)
-            #out, cov = self.pr.lstsq(self.nfunc)
-            #out, cov = self.pr.invert_optimize(self.nfunc)
-            elapsed = time.time()-self.starttime
+            elapsed = time.time() - self.starttime
             self.complete(out=out, cov=cov, pr=self.pr, elapsed=elapsed)
         except KeyboardInterrupt:
@@ -51,5 +42,5 @@
             pass
         except:
-            if not self.error_func==None:
+            if not self.error_func == None:
                 self.error_func("CalcPr.compute: %s" % sys.exc_value)
 
@@ -58,25 +49,18 @@
     Estimate P(r)
     """
-    
-    def __init__(self, pr, nfunc=5, error_func=None,
-                 completefn = None,
-                 updatefn   = None,
-                 yieldtime  = 0.01,
-                 worktime   = 0.01
-                 ):
-        CalcThread.__init__(self,completefn,
-                 updatefn,
-                 yieldtime,
-                 worktime)
+
+    def __init__(self, pr, nfunc=5, error_func=None, completefn=None,
+                 updatefn=None, yieldtime=0.01, worktime=0.01):
+        CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime)
         self.pr = pr
         self.nfunc = nfunc
         self.error_func = error_func
         self.starttime = 0
-        
+
     def compute(self):
         """
         Calculates the estimate
         """
-        try:            
+        try:
             alpha, message, elapsed = self.pr.estimate_alpha(self.nfunc)
             self.isquit()
@@ -86,5 +70,5 @@
             pass
         except:
-            if not self.error_func==None:
+            if not self.error_func == None:
                 self.error_func("EstimatePr.compute: %s" % sys.exc_value)
 
@@ -92,14 +76,7 @@
     """
     """
-    def __init__(self, pr, nfunc=5, error_func=None,
-                 completefn = None,
-                 updatefn   = None,
-                 yieldtime  = 0.01,
-                 worktime   = 0.01
-                 ):
-        CalcThread.__init__(self,completefn,
-                 updatefn,
-                 yieldtime,
-                 worktime)
+    def __init__(self, pr, nfunc=5, error_func=None, completefn=None,
+                 updatefn=None, yieldtime=0.01, worktime=0.01):
+        CalcThread.__init__(self, completefn, updatefn, yieldtime, worktime)
         self.pr = pr
         self.nfunc = nfunc
@@ -114,5 +91,5 @@
         """
         CalcThread.isquit(self)
-        if time.time()>self._time_for_sleep+self._sleep_delay:
+        if time.time() > self._time_for_sleep + self._sleep_delay:
             time.sleep(.2)
             self._time_for_sleep = time.time()
@@ -122,9 +99,9 @@
         Calculates the estimate
         """
-        try:            
+        try:
             t_0 = time.time()
             self._time_for_sleep = t_0
             nterms, alpha, message = self.pr.estimate_numterms(self.isquit)
-            t_1 = time.time()-t_0
+            t_1 = time.time() - t_0
             self.isquit()
             self.complete(nterms=nterms, alpha=alpha, message=message, elapsed=t_1)
@@ -133,4 +110,4 @@
             pass
         except:
-            if not self.error_func==None:
+            if not self.error_func == None:
                 self.error_func("EstimatePr2.compute: %s" % sys.exc_value)
Index: src/sas/perspectives/pr/pr_widgets.py
===================================================================
--- src/sas/perspectives/pr/pr_widgets.py	(revision 794922220f2fb3b23dd08c648aabf87b4850596c)
+++ src/sas/perspectives/pr/pr_widgets.py	(revision 8b21fa7e884f48449cda4fc02c4ab3b6567f4795)
@@ -3,5 +3,5 @@
 #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. 
+#project funded by the US National Science Foundation.
 #
 #See the license text in license.txt
@@ -26,6 +26,6 @@
         ScrolledPanel.__init__(self, *args, **kwds)
         self.SetupScrolling()
-        
-        
+
+
 class PrTextCtrl(wx.TextCtrl):
     """
@@ -34,7 +34,7 @@
     """
     def __init__(self, *args, **kwds):
-        
+
         wx.TextCtrl.__init__(self, *args, **kwds)
-        
+
         ## Set to True when the mouse is clicked while the whole string is selected
         self.full_selection = False
@@ -49,35 +49,35 @@
         Catch when the text control is set in focus to highlight the whole
         text if necessary
-        
+
         :param event: mouse event
-        
+
         """
         event.Skip()
         self.full_selection = True
-        
+
     def _highlight_text(self, event):
         """
         Highlight text of a TextCtrl only of no text has be selected
-        
+
         :param event: mouse event
-        
+
         """
         # Make sure the mouse event is available to other listeners
         event.Skip()
-        control  = event.GetEventObject()
+        control = event.GetEventObject()
         if self.full_selection:
             self.full_selection = False
             # Check that we have a TextCtrl
             if issubclass(control.__class__, wx.TextCtrl):
-                # Check whether text has been selected, 
+                # Check whether text has been selected,
                 # if not, select the whole string
                 (start, end) = control.GetSelection()
-                if start==end:
-                    control.SetSelection(-1,-1)
+                if start == end:
+                    control.SetSelection(-1, -1)
 
 class OutputTextCtrl(wx.TextCtrl):
     """
     Text control used to display outputs.
-    No editing allowed. The background is 
+    No editing allowed. The background is
     grayed out. User can't select text.
     """
@@ -88,17 +88,17 @@
         self.SetEditable(False)
         self.SetBackgroundColour(self.GetParent().GetBackgroundColour())
-        
+
         # Bind to mouse event to avoid text highlighting
         # The event will be skipped once the call-back
         # is called.
         self.Bind(wx.EVT_MOUSE_EVENTS, self._click)
-        
+
     def _click(self, event):
         """
         Prevent further handling of the mouse event
         by not calling Skip().
-        """ 
+        """
         pass
-        
+
 
 class DataFileTextCtrl(OutputTextCtrl):
@@ -106,8 +106,8 @@
     Text control used to display only the file name
     given a full path.
-     
+
     :TODO: now that we no longer choose the data file from the panel,
         it's no longer necessary to pass around the file path. That code
-        should be refactored away and simplified. 
+        should be refactored away and simplified.
     """
     def __init__(self, *args, **kwds):
@@ -116,5 +116,5 @@
         OutputTextCtrl.__init__(self, *args, **kwds)
         self._complete_path = None
-    
+
     def SetValue(self, value):
         """
@@ -122,7 +122,7 @@
         """
         self._complete_path = str(value)
-        file = os.path.basename(self._complete_path)
-        OutputTextCtrl.SetValue(self, file)
-        
+        file_path = os.path.basename(self._complete_path)
+        OutputTextCtrl.SetValue(self, file_path)
+
     def GetValue(self):
         """
@@ -130,26 +130,24 @@
         """
         return self._complete_path
-    
-
-            
-            
+
+
 def load_error(error=None):
     """
     Pop up an error message.
-    
+
     :param error: details error message to be displayed
     """
     message = "The data file you selected could not be loaded.\n"
     message += "Make sure the content of your file is properly formatted.\n\n"
-    
+
     if error is not None:
         message += "When contacting the DANSE team, mention the"
         message += " following:\n%s" % str(error)
-    
+
     dial = wx.MessageDialog(None, message, 'Error Loading File',
                             wx.OK | wx.ICON_EXCLAMATION)
-    dial.ShowModal()    
-
-    
+    dial.ShowModal()
+
+
 class DataDialog(wx.Dialog):
     """
@@ -166,15 +164,12 @@
         self._choice_sizer = wx.GridBagSizer(5, 5)
         self._panel = DialogPanel(self, style=wx.RAISED_BORDER,
-                               size=(WIDTH-20, HEIGHT/3))
-       
+                                  size=(WIDTH - 20, HEIGHT / 3))
+
         self.__do_layout(data_list, text=text)
-        
-        
+
     def __do_layout(self, data_list, text=''):
         """
         layout the dialog
         """
-        #if not data_list or len(data_list) <= 1:
-        #    return 
         #add text
         if text.strip() == "":
@@ -182,41 +177,41 @@
             text += "Please select only one Data.\n"
         text_ctrl = wx.TextCtrl(self, -1, str(text), style=wx.TE_MULTILINE,
-                                size=(-1, HEIGHT/3))
+                                size=(-1, HEIGHT / 3))
         text_ctrl.SetEditable(False)
-        self._sizer_txt.Add(text_ctrl , 1, wx.EXPAND|wx.ALL, 10)
+        self._sizer_txt.Add(text_ctrl, 1, wx.EXPAND | wx.ALL, 10)
         iy = 0
         ix = 0
-        rbox = wx.RadioButton(self._panel, -1, str(data_list[0].name), 
-                                  (10, 10), style= wx.RB_GROUP)
+        rbox = wx.RadioButton(self._panel, -1, str(data_list[0].name),
+                              (10, 10), style=wx.RB_GROUP)
         rbox.SetValue(True)
         self.list_of_ctrl.append((rbox, data_list[0]))
         self._choice_sizer.Add(rbox, (iy, ix), (1, 1),
-                         wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                               wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         for i in range(1, len(data_list)):
             iy += 1
-            rbox = wx.RadioButton(self._panel, -1, 
+            rbox = wx.RadioButton(self._panel, -1,
                                   str(data_list[i].name), (10, 10))
             rbox.SetValue(False)
             self.list_of_ctrl.append((rbox, data_list[i]))
             self._choice_sizer.Add(rbox, (iy, ix),
-                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)
+                                   (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)
         self._panel.SetSizer(self._choice_sizer)
         #add sizer
-        self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0)
+        self._sizer_button.Add((20, 20), 1, wx.EXPAND | wx.ADJUST_MINSIZE, 0)
         button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
         self._sizer_button.Add(button_cancel, 0,
-                          wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
-        button_OK = wx.Button(self, wx.ID_OK, "Ok")
-        button_OK.SetFocus()
-        self._sizer_button.Add(button_OK, 0,
-                                wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10)
+                               wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
+        button_ok = wx.Button(self, wx.ID_OK, "Ok")
+        button_ok.SetFocus()
+        self._sizer_button.Add(button_ok, 0,
+                               wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10)
         static_line = wx.StaticLine(self, -1)
-        
-        self._sizer_txt.Add(self._panel, 0, wx.EXPAND|wx.ALL, 5)
-        self._sizer_main.Add(self._sizer_txt, 0, wx.EXPAND|wx.ALL, 5)
+
+        self._sizer_txt.Add(self._panel, 0, wx.EXPAND | wx.ALL, 5)
+        self._sizer_main.Add(self._sizer_txt, 0, wx.EXPAND | wx.ALL, 5)
         self._sizer_main.Add(static_line, 0, wx.EXPAND, 0)
-        self._sizer_main.Add(self._sizer_button, 0, wx.EXPAND|wx.ALL, 10)
+        self._sizer_main.Add(self._sizer_button, 0, wx.EXPAND | wx.ALL, 10)
         self.SetSizer(self._sizer_main)
-        
+
     def get_data(self):
         """
@@ -226,7 +221,3 @@
             rbox, data = item
             if rbox.GetValue():
-                return data 
-
-    
-
- 
+                return data
