Index: sansmodels/src/sans/models/PorodModel.py
===================================================================
--- sansmodels/src/sans/models/PorodModel.py	(revision 411d8bf82b9bbebc0c79b53d1b4c99783b1eb020)
+++ sansmodels/src/sans/models/PorodModel.py	(revision 499fe7aed93b2a3e2dce0616d6c2cd01ff9cc8ec)
@@ -1,16 +1,13 @@
-#!/usr/bin/env python
 """ 
     Provide I(q) = C/q^4,
     Porod function as a BaseComponent model
 """
-
 from sans.models.BaseComponent import BaseComponent
 import math
 
 class PorodModel(BaseComponent):
-    """ Class that evaluates a Porod model.
-    
-       I(q) = scale/q^4 +background
-        
+    """ 
+        Class that evaluates a Porod model.
+        I(q) = scale/q^4 +background
     """
         
@@ -28,5 +25,5 @@
         self.params['scale'] = 1.0
         self.params['background'] = 0.0
-        self.description= """The Porod model.
+        self.description = """The Porod model.
         I(q) = scale/q^4 +background"""
 
@@ -39,4 +36,8 @@
                
     def _porod(self, x):
+        """
+            Evaluate Porod function
+            :param x: q-value
+        """
         return self.params['scale']/x**4.0 + self.params['background']
    
@@ -49,5 +50,5 @@
             return self._porod(x[0])
         elif x.__class__.__name__ == 'tuple':
-            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+            raise ValueError, "Tuples are not allowed as input to models"
         else:
             return self._porod(x)
@@ -62,5 +63,5 @@
             return self._porod(q)
         elif x.__class__.__name__ == 'tuple':
-            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+            raise ValueError, "Tuples are not allowed as input to models"
         else:
             return self._porod(x)
Index: sansmodels/src/sans/models/PowerLawAbsModel.py
===================================================================
--- sansmodels/src/sans/models/PowerLawAbsModel.py	(revision 9ce41c6f9cb652f9c0a81a779f2dd143382ac661)
+++ sansmodels/src/sans/models/PowerLawAbsModel.py	(revision 499fe7aed93b2a3e2dce0616d6c2cd01ff9cc8ec)
@@ -1,10 +1,9 @@
-#!/usr/bin/env python
 """ 
     Provide F(x) = scale* (|x|)^(-m) + bkd
     Power law function as a BaseComponent model
 """
-
 from sans.models.PowerLawModel import PowerLawModel
 import math
+
 class PowerLawAbsModel(PowerLawModel):
     """
@@ -25,5 +24,5 @@
         ## Name of the model
         self.name = "Absolute Power_Law"
-        self.description=""" The Power_Law model.
+        self.description = """ The Power_Law model.
         F(x) = scale* (|x|)^(-m) + bkd
         
Index: sansmodels/src/sans/models/PowerLawModel.py
===================================================================
--- sansmodels/src/sans/models/PowerLawModel.py	(revision 9ce41c6f9cb652f9c0a81a779f2dd143382ac661)
+++ sansmodels/src/sans/models/PowerLawModel.py	(revision 499fe7aed93b2a3e2dce0616d6c2cd01ff9cc8ec)
@@ -1,13 +1,10 @@
-#!/usr/bin/env python
 """ 
     Provide F(x) = scale* (x)^(-m) + bkd
     Power law function as a BaseComponent model
 """
-
 from sans.models.BaseComponent import BaseComponent
 import math
 
 class PowerLawModel(BaseComponent):
-   
     """
         Class that evaluates a Power_Law model.
@@ -35,5 +32,5 @@
         self.params['scale']        = 1.0
         self.params['background']   = 0.0
-        self.description=""" The Power_Law model.
+        self.description = """ The Power_Law model.
         F(x) = scale* (x)^(-m) + bkd
         
@@ -48,24 +45,22 @@
         self.details['background']  = ['[1/cm]', None, None]
         #list of parameter that cannot be fitted
-        self.fixed= []    
+        self.fixed = []    
     def _PowerLaw(self, x):
         """
             Evaluate  F(x) = scale* (x)^(-m) + bkd
-           
+            :param x: q-value
         """
-        #if x!=0 and self.params['m']!=0:
-        #   raise ValueError, "negative number cannot be raised to a fractional power"
-        if self.params['m']>0  and x==0:
+        if self.params['m'] > 0 and x == 0:
             return 1e+32
-        elif self.params['m']==0  and x==0:
+        elif self.params['m'] == 0 and x == 0:
             return 1
         else:
-            return self.params['scale']*math.pow(x ,-1.0*self.params['m'])\
+            return self.params['scale']*math.pow(x, -1.0*self.params['m'])\
                 + self.params['background']
        
     def run(self, x = 0.0):
         """ Evaluate the model
-            @param x: input q-value (float or [float, float] as [r, theta])
-            @return: (PowerLaw value)
+            :param x: input q-value (float or [float, float] as [r, theta])
+            :return: (PowerLaw value)
         """
         if x.__class__.__name__ == 'list':
@@ -76,5 +71,5 @@
             return self._PowerLaw(math.fabs(x[0]))
         elif x.__class__.__name__ == 'tuple':
-            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+            raise ValueError, "Tuples are not allowed as input to models"
         else:
             return self._PowerLaw(x)
@@ -89,5 +84,5 @@
             return self._PowerLaw(q)
         elif x.__class__.__name__ == 'tuple':
-            raise ValueError, "Tuples are not allowed as input to BaseComponent models"
+            raise ValueError, "Tuples are not allowed as input to models"
         else:
             return self._PowerLaw(x)
Index: sansmodels/src/sans/models/ReflectivityIIModel.py
===================================================================
--- sansmodels/src/sans/models/ReflectivityIIModel.py	(revision 1352c786d3b53b1d20c7d36be8a8351a77c6f8f6)
+++ sansmodels/src/sans/models/ReflectivityIIModel.py	(revision 499fe7aed93b2a3e2dce0616d6c2cd01ff9cc8ec)
@@ -5,5 +5,4 @@
 from math import floor
 from math import fabs
-from scipy.special import erf
 func_list = {'Erf(|nu|*z)':0, 'RPower(z^|nu|)':1, 'LPower(z^|nu|)':2, \
                      'RExp(-|nu|*z)':3, 'LExp(-|nu|*z)':4}
@@ -15,16 +14,16 @@
     """
     def __init__(self, multfactor=1):
+        """
+            :param multfactor: number of layers in the model, 
+            assumes 0<= n_layers <=10.
+        """
         BaseComponent.__init__(self)
-        """
-        :param multfactor: number of layers in the model, 
-        assumes 0<= n_layers <=10.
-        """
 
         ## Setting  model name model description
-        self.description=""
+        self.description = ""
         model = ReflAdvModel()
         self.model = model
         self.name = "ReflectivityIIModel"
-        self.description=model.description
+        self.description = model.description
         self.n_layers = int(multfactor)
         ## Define parameters
@@ -54,5 +53,5 @@
         # [int(maximum no. of functionality),"str(Titl),
         # [str(name of function0),...], [str(x-asix name of sld),...]]
-        self.multiplicity_info = [max_nshells,"No. of Layers:",[],['Depth']]
+        self.multiplicity_info = [max_nshells, "No. of Layers:", [], ['Depth']]
         ## independent parameter name and unit [string]
         self.input_name = "Q"
@@ -92,5 +91,5 @@
         """
         # rearrange the parameters for the given # of shells
-        for name , value in self.model.params.iteritems():
+        for name, value in self.model.params.iteritems():
             n = 0
             pos = len(name.split('_'))-1
@@ -103,29 +102,29 @@
                 continue
             elif first_name == 'func':
-                n= -1
-                while n<self.n_layers:
+                n = -1
+                while n < self.n_layers:
                     n += 1
                     if last_name == 'inter%s' % str(n): 
-                        self.params[name]=value
+                        self.params[name] = value
                         continue
             
                 #continue
             elif last_name[0:5] == 'inter':
-                n= -1
-                while n<self.n_layers:
+                n = -1
+                while n < self.n_layers:
                     n += 1
                     if last_name == 'inter%s' % str(n):
-                        self.params[name]= value
+                        self.params[name] = value
                         continue
             elif last_name[0:4] == 'flat':
-                while n<self.n_layers:
+                while n < self.n_layers:
                     n += 1
                     if last_name == 'flat%s' % str(n):
-                        self.params[name]= value
+                        self.params[name] = value
                         continue
             elif name == 'n_layers':
                 continue
             else:
-                self.params[name]= value
+                self.params[name] = value
   
         self.model.params['n_layers'] = self.n_layers    
@@ -139,7 +138,7 @@
         this model details 
         """
-        for name ,detail in self.model.details.iteritems():
+        for name, detail in self.model.details.iteritems():
             if name in self.params.iterkeys():
-                self.details[name]= detail
+                self.details[name] = detail
             
     
@@ -155,6 +154,6 @@
                     continue
                 if  key.split('_')[0] == 'func': 
-                        self.model.setParam(key, 0)
-                        continue
+                    self.model.setParam(key, 0)
+                    continue
 
                 for nshell in range(self.n_layers,max_nshells):
@@ -166,11 +165,12 @@
                                 value = self.model.params['sldIM_medium']
                             self.model.setParam(key, value)
-                        except: pass
+                        except:
+                            message = "ReflectivityIIModel evaluation problem"
+                            raise RuntimeError, message
     
     def _get_func_list(self):
         """
-        Get the list of functions in each layer (shell) 
-        """
-        #func_list = {}
+            Get the list of functions in each layer (shell) 
+        """
         return func_list
         
@@ -186,5 +186,4 @@
         z = []
         beta = []
-        sub_range = int(floor(n_sub/2.0))
         z.append(0)
         beta.append(self.params['sld_bottom0']) 
@@ -193,24 +192,24 @@
         dz = 0.0
         # for layers from the top
-        for n_lyr in range(1,self.n_layers+2):
+        for n_lyr in range(1, self.n_layers+2):
             i = n_lyr
             # j=0 for interface, j=1 for flat layer 
-            for j in range(0,2):
+            for j in range(0, 2):
                 # interation for sub-layers
-                for n_s in range(0,n_sub):
+                for n_s in range(0, n_sub):
                     # for flat layer
-                    if j==1:
-                        if i==self.n_layers+1:
+                    if j == 1:
+                        if i == self.n_layers+1:
                             break
                         # shift half sub thickness for the first point
                         z0 -= dz/2.0
                         z.append(z0)
-                        sld_i = self.params['sld_flat%s'% str(i)]
+                        sld_i = self.params['sld_flat%s' % str(i)]
                         beta.append(sld_i)
-                        dz = self.params['thick_flat%s'% str(i)]
+                        dz = self.params['thick_flat%s' % str(i)]
                         z0 += dz
                     else:
-                        dz = self.params['thick_inter%s'% str(i-1)]/n_sub
-                        nu = fabs(self.params['nu_inter%s'% str(i-1)])
+                        dz = self.params['thick_inter%s' % str(i-1)]/n_sub
+                        nu = fabs(self.params['nu_inter%s' % str(i-1)])
                         if n_s == 0:
                             # shift half sub thickness for the point
@@ -220,13 +219,13 @@
                             sld_l = self.params['sld_bottom0']
                         else:
-                            sld_l = self.params['sld_flat%s'% str(i-1)]
+                            sld_l = self.params['sld_flat%s' % str(i-1)]
                         if i == self.n_layers+1:
                             sld_r = self.params['sld_medium']
                         else:
-                            sld_r = self.params['sld_flat%s'% str(i)]
+                            sld_r = self.params['sld_flat%s' % str(i)]
                         if sld_r == sld_l:
                             sld_i = sld_r
                         else:
-                            func_idx = self.params['func_inter%s'% str(i-1)]
+                            func_idx = self.params['func_inter%s' % str(i-1)]
                             # calculate the sld
                             sld_i = self._get_sld(func_idx, n_sub, n_s+0.5, nu,
@@ -235,6 +234,8 @@
                     z.append(z0)
                     beta.append(sld_i)
-                    if j==1: break
-                    else: z0 += dz
+                    if j == 1: 
+                        break
+                    else: 
+                        z0 += dz
         # put substrate and superstrate profile
         z.append(z0)
@@ -246,6 +247,6 @@
         z.append(z0+z_ext)
         beta.append(self.params['sld_medium']) 
-        z.insert(0,-z_ext)
-        beta.insert(0,self.params['sld_bottom0']) 
+        z.insert(0, -z_ext)
+        beta.insert(0, self.params['sld_bottom0']) 
         # rearrange the profile for NR sld profile style
         z = [z0 - x for x in z]
@@ -269,10 +270,10 @@
         sld_cal = SLDCalFunc()
         # set params
-        sld_cal.setParam('fun_type',func_idx)
-        sld_cal.setParam('npts_inter',n_sub)
-        sld_cal.setParam('shell_num',n_s)
-        sld_cal.setParam('nu_inter',nu)
-        sld_cal.setParam('sld_left',sld_l)
-        sld_cal.setParam('sld_right',sld_r)
+        sld_cal.setParam('fun_type', func_idx)
+        sld_cal.setParam('npts_inter', n_sub)
+        sld_cal.setParam('shell_num', n_s)
+        sld_cal.setParam('nu_inter', nu)
+        sld_cal.setParam('sld_left', sld_l)
+        sld_cal.setParam('sld_right', sld_r)
         # return sld value
         return sld_cal.run()
@@ -289,10 +290,10 @@
         
         ## setParam to model 
-        if name=='sld_medium':
+        if name == 'sld_medium':
             # the sld_*** model.params not in params must set 
             # to value of sld_solv
             for key in self.model.params.iterkeys():
                 if key not in self.params.keys()and key.split('_')[0] == 'sld':
-                        self.model.setParam(key, value)   
+                    self.model.setParam(key, value)   
         
         self.model.setParam( name, value)
@@ -342,5 +343,5 @@
     ## Now (May27,10) directly uses the model eval function 
     ## instead of the for-loop in Base Component.
-    def evalDistribution(self, x = []):
+    def evalDistribution(self, x):
         """ 
         Evaluate the model in cartesian coordinates
Index: sansmodels/src/sans/models/ReflectivityModel.py
===================================================================
--- sansmodels/src/sans/models/ReflectivityModel.py	(revision 1352c786d3b53b1d20c7d36be8a8351a77c6f8f6)
+++ sansmodels/src/sans/models/ReflectivityModel.py	(revision 499fe7aed93b2a3e2dce0616d6c2cd01ff9cc8ec)
@@ -7,4 +7,5 @@
 func_list = {'Erf':0, 'Linear':1}
 max_nshells = 10
+
 class ReflectivityModel(BaseComponent):
     """
@@ -13,16 +14,16 @@
     """
     def __init__(self, multfactor=1):
+        """
+            :param multfactor: number of layers in the model, 
+            assumes 0<= n_shells <=10.
+        """
         BaseComponent.__init__(self)
-        """
-        :param multfactor: number of layers in the model, 
-        assumes 0<= n_shells <=10.
-        """
 
         ## Setting  model name model description
-        self.description=""
+        self.description = ""
         model = ReflModel()
         self.model = model
         self.name = "ReflectivityModel"
-        self.description=model.description
+        self.description = model.description
         self.n_layers = int(multfactor)
         ## Define parameters
@@ -52,5 +53,5 @@
         # [int(maximum no. of functionality),"str(Titl),
         # [str(name of function0),...], [str(x-asix name of sld),...]]
-        self.multiplicity_info = [max_nshells,"No. of Layers:",[],['Depth']]
+        self.multiplicity_info = [max_nshells, "No. of Layers:", [], ['Depth']]
         ## independent parameter name and unit [string]
         self.input_name = "Q"
@@ -95,28 +96,28 @@
                 continue
             elif name.split('_')[0] == 'func':
-                n= -1
-                while n<self.n_layers:
+                n = -1
+                while n < self.n_layers:
                     n += 1
                     if name.split('_')[pos] == 'inter%s' % str(n):
-                        self.params[name]=value
+                        self.params[name] = value
                         continue
                 #continue
             elif name.split('_')[pos][0:5] == 'inter':
-                n= -1
-                while n<self.n_layers:
+                n = -1
+                while n < self.n_layers:
                     n += 1
                     if name.split('_')[pos] == 'inter%s' % str(n):
-                        self.params[name]= value
+                        self.params[name] = value
                         continue
             elif name.split('_')[pos][0:4] == 'flat':
-                while n<self.n_layers:
+                while n < self.n_layers:
                     n += 1
                     if name.split('_')[pos] == 'flat%s' % str(n):
-                        self.params[name]= value
+                        self.params[name] = value
                         continue
             elif name == 'n_layers':
                 continue
             else:
-                self.params[name]= value
+                self.params[name] = value
                
         self.model.params['n_layers'] = self.n_layers    
@@ -130,7 +131,7 @@
         this model details 
         """
-        for name ,detail in self.model.details.iteritems():
+        for name, detail in self.model.details.iteritems():
             if name in self.params.iterkeys():
-                self.details[name]= detail
+                self.details[name] = detail
             
     
@@ -156,5 +157,6 @@
                                 value = self.model.params['sldIM_medium']
                             self.model.setParam(key, value)
-                        except: pass
+                        except:
+                            raise RuntimeError, "ReflectivityModel problem"
     
     def _get_func_list(self):
@@ -182,11 +184,12 @@
         z0 = 0
         # for layers from the top
-        for n in range(1,self.n_layers+2):
+        for n in range(1, self.n_layers+2):
             i = n
 
-            for j in range(0,2):
-                for n_s in range(-sub_range,sub_range+1):
-                    if j==1:
-                        if i==self.n_layers+1:
+            for j in range(0, 2):
+                for n_s in range(-sub_range, sub_range+1): 
+                    dz = self.params['thick_inter%s' % str(i-1)]/n_sub
+                    if j == 1:
+                        if i == self.n_layers+1:
                             break
                         # shift half sub thickness for the first point
@@ -194,12 +197,9 @@
                         z.append(z0)
                         #z0 -= dz/2.0
-                        z0 += self.params['thick_flat%s'% str(i)]
+                        z0 += self.params['thick_flat%s' % str(i)]
                         
-                        sld_i = self.params['sld_flat%s'% str(i)]
-                        beta.append(self.params['sld_flat%s'% str(i)])
+                        sld_i = self.params['sld_flat%s' % str(i)]
+                        beta.append(self.params['sld_flat%s' % str(i)])
                     else:
-                        
-                        dz = self.params['thick_inter%s'% str(i-1)]/n_sub
-                        
                         if n_s == -sub_range:
                             # shift half sub thickness for the first point
@@ -212,20 +212,21 @@
                             sld_l = self.params['sld_bottom0']
                         else:
-                            sld_l = self.params['sld_flat%s'% str(i-1)]
+                            sld_l = self.params['sld_flat%s' % str(i-1)]
                         if i == self.n_layers+1:
                             sld_r = self.params['sld_medium']
                         else:
-                            sld_r = self.params['sld_flat%s'% str(i)]
-                        func_idx = self.params['func_inter%s'% str(i-1)]
+                            sld_r = self.params['sld_flat%s' % str(i)]
+                        func_idx = self.params['func_inter%s' % str(i-1)]
                         func = self._get_func(n_s, n_sub, func_idx)
-                        if sld_r>sld_l:
+                        if sld_r > sld_l:
                             sld_i = (sld_r-sld_l)*func+sld_l
-                        elif sld_r<sld_l:
+                        elif sld_r < sld_l:
                             sld_i = (sld_l-sld_r)*(1-func)+sld_r
                         else:
-                             sld_i = sld_r
+                            sld_i = sld_r
                     z.append(z0)
                     beta.append(sld_i)
-                    if j==1: break
+                    if j == 1:
+                        break
         # put substrate and superstrate profile
         # shift half sub thickness for the first point
@@ -239,6 +240,6 @@
         z.append(z0+z_ext)
         beta.append(self.params['sld_medium']) 
-        z.insert(0,-z_ext)
-        beta.insert(0,self.params['sld_bottom0']) 
+        z.insert(0, -z_ext)
+        beta.insert(0, self.params['sld_bottom0']) 
         z = [z0 - x for x in z]
         z.reverse()
@@ -298,10 +299,10 @@
         
         ## setParam to model 
-        if name=='sld_medium':
+        if name == 'sld_medium':
             # the sld_*** model.params not in params must set 
             # to value of sld_solv
             for key in self.model.params.iterkeys():
                 if key not in self.params.keys()and key.split('_')[0] == 'sld':
-                        self.model.setParam(key, value)
+                    self.model.setParam(key, value)
             
         self.model.setParam( name, value)
@@ -351,5 +352,5 @@
     ## Now (May27,10) directly uses the model eval function 
     ## instead of the for-loop in Base Component.
-    def evalDistribution(self, x = []):
+    def evalDistribution(self, x):
         """ 
         Evaluate the model in cartesian coordinates
@@ -360,8 +361,10 @@
         # set effective radius and scaling factor before run
         return self.model.evalDistribution(x)
+    
     def calculate_ER(self):
         """
         """
         return self.model.calculate_ER()
+    
     def set_dispersion(self, parameter, dispersion):
         """
