Changeset 31f9d0c2 in sasview for sansmodels


Ignore:
Timestamp:
Apr 18, 2012 10:01:15 AM (13 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7fb69f26
Parents:
7343319
Message:

Fixing code style problems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/FractalCoreShellModel.py

    r18695bf r31f9d0c2  
    1     
     1""" 
     2    Fractal Core-Shell model 
     3""" 
    24from sans.models.BaseComponent import BaseComponent 
    35from sans.models.CoreShellModel import CoreShellModel 
    46from scipy.special import gammaln 
    5 from math import exp, sin, atan 
     7import math 
    68from numpy import power 
    79from copy import deepcopy 
     
    2628        ## Setting  model name model description 
    2729        model = CoreShellModel() 
    28         self.description=model 
     30        self.description = model 
    2931         
    3032        self.model = model 
    3133        self.name = "FractalCoreShell" 
    32         self.description="""Scattering  from a fractal structure  
     34        self.description = """Scattering  from a fractal structure  
    3335        with a primary building block of a spherical particle  
    3436        with particle with a core-shell structure. 
     
    6466        self._set_details() 
    6567 
    66         ## parameters with orientation: can be removed since there is no orientational params 
     68        ## parameters with orientation: 
    6769        for item in self.model.orientation_params: 
    6870            self.orientation_params.append(item) 
    6971                 
    70     def _fractalcore(self,x): 
     72    def _fractalcore(self, x): 
    7173        """ 
    7274        Define model function 
     
    7981        r0 = self.params['radius'] 
    8082        #calculate S(q) 
    81         sq = Df*exp(gammaln(Df-1.0))*sin((Df-1.0)*atan(x*corr)) 
    82         sq /= power((x*r0),Df) * power((1.0 + 1.0/(x*corr*x*corr)),((Df-1)/2)) 
     83        sq = Df*math.exp(gammaln(Df-1.0))*math.sin((Df-1.0)*math.atan(x*corr)) 
     84        sq /= power((x*r0), Df) * power((1.0 + 1.0/(x*corr*x*corr)), ((Df-1)/2)) 
    8385        sq += 1.0 
    8486        return sq 
     
    103105        ##set dispersion from model  
    104106        for name , value in self.model.dispersion.iteritems():       
    105             self.dispersion[name]= value 
     107            self.dispersion[name] = value 
    106108                               
    107109    def _set_params(self): 
     
    126128            elif name == 'background': 
    127129                value = 0.0 
    128             self.model.params[name]= value 
     130            self.model.params[name] = value 
    129131            if name  == 'scale': 
    130132                name = 'volfraction' 
     
    138140        this model details  
    139141        """ 
    140         for name ,detail in self.model.details.iteritems(): 
     142        for name, detail in self.model.details.iteritems(): 
    141143            if name in self.params.iterkeys(): 
    142144                if name == 'scale': 
    143145                    name = 'volfraction' 
    144                 self.details[name]= detail 
     146                self.details[name] = detail 
    145147        self.details['frac_dim']   = ['', None, None] 
    146148        self.details['cor_length'] = ['[A]', None, None]   
     
    201203            #qx = math.fabs(x[0]*math.cos(x[1])) 
    202204            #qy = math.fabs(x[0]*math.sin(x[1])) 
    203             return self.params['background']+self._fractalcore(x[0])*self.model.run(x) 
     205            return self.params['background']\ 
     206                +self._fractalcore(x[0])*self.model.run(x) 
    204207        elif x.__class__.__name__ == 'tuple': 
    205208            raise ValueError, "Tuples are not allowed as input to BaseComponent models" 
    206209        else: 
    207             return self.params['background']+self._fractalcore(x)*self.model.run(x) 
    208  
     210            return self.params['background']\ 
     211                +self._fractalcore(x)*self.model.run(x) 
    209212 
    210213        return self.params['background']+self._fractalcore(x)*self.model.run(x) 
     
    233236        :dispersion: dispersion object of type DispersionModel 
    234237        """ 
    235         value= None 
     238        value = None 
    236239        try: 
    237240            if parameter in self.model.dispersion.keys(): 
    238                 value= self.model.set_dispersion(parameter, dispersion) 
     241                value = self.model.set_dispersion(parameter, dispersion) 
    239242            self._set_dispersion() 
    240243            return value 
Note: See TracChangeset for help on using the changeset viewer.