Index: sansmodels/src/sans/models/SphericalSLDModel.py
===================================================================
--- sansmodels/src/sans/models/SphericalSLDModel.py	(revision cd075e8ddcbe66b153c3d0deb86ee258cacb9fdf)
+++ sansmodels/src/sans/models/SphericalSLDModel.py	(revision 2e0053e9f7ceec19009a49ff5ebed57742bfd030)
@@ -1,11 +1,13 @@
-   
+"""
+    Spherical SLD model
+"""
 from sans.models.BaseComponent import BaseComponent
 from sans.models.SphereSLDModel import SphereSLDModel
 from copy import deepcopy
 from math import floor
-#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}
 max_nshells = 10
+
 class SphericalSLDModel(BaseComponent):
     """
@@ -14,16 +16,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 = SphereSLDModel()
         self.model = model
         self.name = "SphericalSLDModel"
-        self.description=model.description
+        self.description = model.description
         self.n_shells = multfactor
         ## Define parameters
@@ -53,5 +55,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 Shells:",[],['Radius']]
+        self.multiplicity_info = [max_nshells, "No. of Shells:", [], ['Radius']]
         
     
@@ -80,12 +82,12 @@
             nshell = -1
             if name.split('_')[0] == 'thick':
-                while nshell<1:
+                while nshell < 1:
                     nshell += 1
                     if name.split('_')[1] == 'inter%s' % str(nshell):
-                        self.dispersion[name]= value
+                        self.dispersion[name] = value
                     else: 
                         continue
             else:
-                self.dispersion[name]= value
+                self.dispersion[name] = value
 
     def _set_params(self):
@@ -101,30 +103,30 @@
             last_name = name.split('_')[pos]
             if first_name == 'npts':
-                self.params[name]=value
+                self.params[name] = value
                 continue
             elif first_name == 'func':
-                n= -1
-                while n<self.n_shells:
+                n = -1
+                while n < self.n_shells:
                     n += 1
                     if last_name == 'inter%s' % str(n): 
-                        self.params[name]=value
+                        self.params[name] = value
                         continue
             elif last_name[0:5] == 'inter':
-                n= -1
-                while n<self.n_shells:
+                n = -1
+                while n < self.n_shells:
                     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_shells:
+                while n < self.n_shells:
                     n += 1
                     if last_name == 'flat%s' % str(n):
-                        self.params[name]= value
+                        self.params[name] = value
                         continue
             elif name == 'n_shells':
                 continue
             else:
-                self.params[name]= value
+                self.params[name] = value
   
         self.model.params['n_shells'] = self.n_shells    
@@ -138,7 +140,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
             
     
@@ -150,10 +152,10 @@
         for key in self.model.params.iterkeys():
             if key not in self.params.keys():
-                if  key.split('_')[0] == 'thick':
+                if key.split('_')[0] == 'thick':
                     self.model.setParam(key, 0)
                     continue
-                if  key.split('_')[0] == 'func': 
-                        self.model.setParam(key, 0)
-                        continue
+                if key.split('_')[0] == 'func': 
+                    self.model.setParam(key, 0)
+                    continue
 
                 for nshell in range(self.n_shells,max_nshells):
@@ -163,5 +165,6 @@
                                 value = self.model.params['sld_solv']
                             self.model.setParam(key, value)
-                        except: pass
+                        except:
+                            raise RuntimeError, "SphericalSLD model problem"
     
     def _get_func_list(self):
@@ -169,5 +172,4 @@
         Get the list of functions in each layer (shell) 
         """
-        #func_list = {}
         return func_list
         
@@ -184,5 +186,4 @@
         beta = []
         z0 = 0
-        sub_range = floor(n_sub/2.0)
         # two sld points for core
         z.append(0)
@@ -192,12 +193,13 @@
         z0 += self.params['rad_core0']
         # for layers from the core
-        for n in range(1,self.n_shells+2):
+        for n in range(1, self.n_shells+2):
             i = n
+            dz = self.params['thick_inter%s'% str(i-1)]/n_sub
             # 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+1):
-                    if j==1:
-                        if i==self.n_shells+1:
+                for n_s in range(0, n_sub+1):
+                    if j == 1:
+                        if i == self.n_shells+1:
                             break
                         # shift half sub thickness for the first point
@@ -205,23 +207,22 @@
                         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)])
                         dz = 0
                     else:
-                        dz = self.params['thick_inter%s'% str(i-1)]/n_sub
-                        nu = self.params['nu_inter%s'% str(i-1)]
+                        nu = self.params['nu_inter%s' % str(i-1)]
                         # decide which sld is which, sld_r or sld_l
                         if i == 1:
                             sld_l = self.params['sld_core0']
                         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_shells+1:
                             sld_r = self.params['sld_solv']
                         else:
-                            sld_r = self.params['sld_flat%s'% str(i)]
+                            sld_r = self.params['sld_flat%s' % str(i)]
                         # get function type
-                        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, nu,
@@ -231,5 +232,6 @@
                     beta.append(sld_i)
                     z0 += dz
-                    if j==1: break
+                    if j == 1:
+                        break
         # put sld of solvent
         z.append(z0)
@@ -256,10 +258,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()
@@ -273,15 +275,15 @@
         """
         # set param to new model
-        self._setParamHelper( name, value)
+        self._setParamHelper(name, value)
         
         ## setParam to model 
-        if name=='sld_solv':
+        if name == 'sld_solv':
             # 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)
+                if key not in self.params.keys() and key.split('_')[0] == 'sld':
+                    self.model.setParam(key, value)
             
-        self.model.setParam( name, value)
+        self.model.setParam(name, value)
 
     def _setParamHelper(self, name, value):
@@ -290,7 +292,7 @@
         """
         toks = name.split('.')
-        if len(toks)==2:
+        if len(toks) == 2:
             for item in self.dispersion.keys():
-                if item.lower()==toks[0].lower():
+                if item.lower() == toks[0].lower():
                     for par in self.dispersion[item]:
                         if par.lower() == toks[1].lower():
@@ -299,5 +301,5 @@
         # Look for standard parameter
         for item in self.params.keys():
-            if item.lower()==name.lower():
+            if item.lower() == name.lower():
                 self.params[item] = value
                 return
@@ -315,5 +317,4 @@
 
         self.fixed.sort()
-        pass         
 
     def run(self, x = 0.0):
@@ -341,5 +342,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
@@ -350,8 +351,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):
         """
@@ -361,10 +364,7 @@
         :dispersion: dispersion object of type DispersionModel
         """
-        value= None
-        try:
-            if parameter in self.model.dispersion.keys():
-                value= self.model.set_dispersion(parameter, dispersion)
-            self._set_dispersion()
-            return value
-        except:
-            raise 
+        value = None
+        if parameter in self.model.dispersion.keys():
+            value = self.model.set_dispersion(parameter, dispersion)
+        self._set_dispersion()
+        return value
