Index: inversionview/src/sans/perspectives/pr/pr.py
===================================================================
--- inversionview/src/sans/perspectives/pr/pr.py	(revision 6813da7d4dc32b0199b931ad78f7bb3500504a68)
+++ inversionview/src/sans/perspectives/pr/pr.py	(revision 4b73c3eb44368e18944a437816f257b246d3c477)
@@ -19,5 +19,4 @@
 import logging
 import time
-import copy
 import math
 import numpy
@@ -47,4 +46,5 @@
 class Plugin(PluginBase):
     """
+        P(r) inversion perspective
     """
     DEFAULT_ALPHA = 0.0001
@@ -119,13 +119,9 @@
         delete the data association with prview
         """
-        if self.calc_thread is not None and self.calc_thread.isrunning():
-            msg = "Data in use in Prview\n"
-        if self.estimation_thread is not None and \
-            self.estimation_thread.isrunning():
-             msg = "Data in use in Prview\n"
         self.control_panel.clear_panel()
        
     def get_data(self):
         """
+            Returns the current data
         """
         return self.current_plottable
@@ -149,5 +145,7 @@
                 data = datainfo
             if data is None:
-                raise RuntimeError, "Pr.set_state: datainfo parameter cannot be None in standalone mode"
+                msg =  "Pr.set_state: datainfo parameter cannot "
+                msg += "be None in standalone mode"
+                raise RuntimeError, msg
             
             # Ensuring that plots are coordinated correctly
@@ -160,5 +158,8 @@
                 max_char = len(data.meta_data['prstate'].file)
             
-            datainfo.meta_data['prstate'].file = data.meta_data['prstate'].file[0:max_char] +' [' + time_str + ']'
+            datainfo.meta_data['prstate'].file =\
+                data.meta_data['prstate'].file[0:max_char]\
+                + ' [' + time_str + ']'
+            
             data.filename = data.meta_data['prstate'].file
             # TODO:
@@ -166,5 +167,5 @@
             # such as ID , Group_ID, etc...
             #make self.current_plottable = datainfo directly
-            self.current_plottable = self.parent.create_gui_data(data,None)
+            self.current_plottable = self.parent.create_gui_data(data, None)
             self.current_plottable.group_id = data.meta_data['prstate'].file
             
@@ -200,5 +201,4 @@
         """
         """
-        from sans.pr.invertor import Invertor
         # Generate P(r) for sphere
         radius = 60.0
@@ -289,5 +289,5 @@
         """  
         qtemp = pr.x
-        if not q==None:
+        if not q == None:
             qtemp = q
 
@@ -301,7 +301,7 @@
         
         # Check for user min/max
-        if not pr.q_min==None:
+        if not pr.q_min == None:
             minq = pr.q_min
-        if not pr.q_max==None:
+        if not pr.q_max == None:
             maxq = pr.q_max
                 
@@ -335,5 +335,5 @@
         
         # If we have used slit smearing, plot the smeared I(q) too
-        if pr.slit_width>0 or pr.slit_height>0:
+        if pr.slit_width > 0 or pr.slit_height > 0:
             x = pylab.arange(minq, maxq, maxq/301.0)
             y = numpy.zeros(len(x))
@@ -480,5 +480,4 @@
         Load 2- or 3- column ascii
         """
-        import numpy, math, sys
         # Read the data from the data file
         data_x   = numpy.zeros(0)
@@ -529,5 +528,4 @@
         
         """
-        import numpy, math, sys
         # Read the data from the data file
         data_x   = numpy.zeros(0)
@@ -543,5 +541,5 @@
             lines   = buff.split('\n')
             for line in lines:
-                if data_started==True:
+                if data_started == True:
                     try:
                         toks = line.split()
@@ -551,5 +549,5 @@
                             err = float(toks[2])
                         else:
-                            if scale==None:
+                            if scale == None:
                                 scale = 0.05*math.sqrt(y)
                                 #scale = 0.05/math.sqrt(y)
@@ -566,5 +564,5 @@
                     data_started = True      
                    
-        if not scale==None:
+        if not scale == None:
             message = "The loaded file had no error bars, statistical errors are assumed."
             wx.PostEvent(self.parent, StatusEvent(status=message))
@@ -576,6 +574,8 @@
     def pr_theory(self, r, R):
         """  
-        """
-        if r<=2*R:
+            Return P(r) of a sphere for a given R 
+            For test purposes
+        """
+        if r <= 2*R:
             return 12.0* ((0.5*r/R)**2) * ((1.0-0.5*r/R)**2) * ( 2.0 + 0.5*r/R )
         else:
@@ -623,5 +623,5 @@
             return []
         elif item.id == graph.selected_plottable:
-	       if not self.standalone and issubclass(item.__class__, Data1D):
+           if not self.standalone and issubclass(item.__class__, Data1D):
                 return [["Compute P(r)", 
                              "Compute P(r) from distribution", 
@@ -714,61 +714,9 @@
                          NewPlotEvent(plot=new_plot, update=True,
                                 title=self._added_plots[plot].name))        
-        
-        
-    def _on_add_data(self, evt):
-        """
-        Add a data curve to the plot
-        
-        :WARNING: this will be removed once guiframe.plotting has
-             its full functionality
-        """
-        path = self.choose_file()
-        if path==None:
-            return
-        
-        #x, y, err = self.parent.load_ascii_1D(path)
-        # Use data loader to load file
-        try:
-            dataread = Loader().load(path)
-            x = None
-            y = None
-            err = None
-            if dataread.__class__.__name__ == 'Data1D':
-                x = dataread.x
-                y = dataread.y
-                err = dataread.dy
-            else:
-                if isinstance(dataread, list) and len(dataread)>0:
-                    x = dataread[0].x
-                    y = dataread[0].y
-                    err = dataread[0].dy
-                    msg = "PrView only allows a single data set at a time. "
-                    msg += "Only the first data set was loaded." 
-                    wx.PostEvent(self.parent, StatusEvent(status=msg))
-                else:
-                    msg = "This tool can only read 1D data"
-                    wx.PostEvent(self.parent, StatusEvent(status=msg))
-                    return
-            
-        except:
-            wx.PostEvent(self.parent, StatusEvent(status=sys.exc_value))
-            return
-        
-        filename = os.path.basename(path)
-        new_plot = Data1D(x, y)
-        new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM
-        new_plot.name = filename
-        new_plot.xaxis("\\rm{r}", 'A')
-        new_plot.yaxis("\\rm{P(r)} ","cm^{-3}")
-        # Store a ref to the plottable for later use
-        self._added_plots[filename] = new_plot
-        self._default_Iq[filename]  = numpy.copy(y)
-        wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title=filename))
-        
+                
     def start_thread(self):
         """
         """
         from pr_thread import CalcPr
-        from copy import deepcopy
         
         # If a thread is already started, stop it
@@ -846,5 +794,4 @@
         
         """
-        from copy import deepcopy
         # Save useful info
         self.elapsed = elapsed
@@ -867,6 +814,4 @@
         self.control_panel.elapsed = elapsed
         self.control_panel.oscillation = pr.oscillations(out)
-        #print "OSCILL", pr.oscillations(out)
-        #print "PEAKS:", pr.get_peaks(out) 
         self.control_panel.positive = pr.get_positive(out)
         self.control_panel.pos_err  = pr.get_pos_err(out, cov)
@@ -874,26 +819,5 @@
         self.control_panel.iq0 = pr.iq0(out)
         self.control_panel.bck = pr.background
-        
-        if False:
-            for i in range(len(out)):
-                try:
-                    print "%d: %g +- %g" % (i, out[i],
-                                             math.sqrt(math.fabs(cov[i][i])))
-                except: 
-                    print sys.exc_value
-                    print "%d: %g +- ?" % (i, out[i])        
-        
-            # Make a plot of I(q) data
-            new_plot = Data1D(self.pr.x, self.pr.y, dy=self.pr.err)
-            new_plot.name = IQ_DATA_LABEL
-            new_plot.xaxis("\\rm{Q}", 'A^{-1}')
-            new_plot.yaxis("\\rm{Intensity} ","cm^{-1}")
-            if pr.info.has_key("plot_group_id"):
-                new_plot.group_id = pr.info["plot_group_id"]
-            new_plot.id = self.data_id
-            self.parent.update_theory(data_id=self.data_id,
-                                       theory=new_plot)
-            wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, title="Iq"))
-                
+                        
         # Show I(q) fit
         self.show_iq(out, self.pr)
@@ -901,9 +825,5 @@
         # Show P(r) fit
         x_values, x_range = self.show_pr(out, self.pr, cov)  
-        
-        # Popup result panel
-        #result_panel = InversionResults(self.parent, 
-        #-1, style=wx.RAISED_BORDER)
-        
+                
     def show_data(self, path=None, data=None, reset=False):
         """
@@ -1399,6 +1319,6 @@
                     self.control_panel._change_file(evt=None, data=data)
                 except:
-                     msg = "Prview Set_data: " + str(sys.exc_value)
-                     wx.PostEvent(self.parent, StatusEvent(status=msg,
+                    msg = "Prview Set_data: " + str(sys.exc_value)
+                    wx.PostEvent(self.parent, StatusEvent(status=msg,
                                                             info="error"))
             else:    
