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
