Ignore:
Timestamp:
Dec 14, 2009 8:39:21 AM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
6e9976b
Parents:
7975f2b
Message:

implement set and get state

File:
1 edited

Legend:

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

    rf9bf661 rfe9c19b4  
    2828class Gaussian(CGaussian, BaseComponent): 
    2929    """ Class that evaluates a Gaussian model.  
    30         This file was auto-generated from ..\c_extensions\gaussian.h. 
    31         Refer to that file and the structure it contains 
    32         for details of the model. 
    33         List of default parameters: 
     30        This file was auto-generated from ..\c_extensions\gaussian.h. 
     31        Refer to that file and the structure it contains 
     32        for details of the model. 
     33        List of default parameters: 
    3434         scale           = 1.0  
    3535         sigma           = 1.0  
     
    5050        self.description ="""f(x)=scale * 1/(sigma^2*2pi)e^(-(x-mu)^2/2sigma^2)""" 
    5151        
    52                 ## Parameter details [units, min, max] 
     52        ## Parameter details [units, min, max] 
    5353        self.details = {} 
    5454        self.details['scale'] = ['', None, None] 
     
    5656        self.details['center'] = ['', None, None] 
    5757 
    58                 ## fittable parameters 
     58        ## fittable parameters 
    5959        self.fixed=[] 
    6060         
     
    6565        """ Return a identical copy of self """ 
    6666        return self._clone(Gaussian())    
     67         
     68    def __getstate__(self): 
     69        """ return object state for pickling and copying """ 
     70        print "__dict__",self.__dict__ 
     71        #self.__dict__['params'] = self.params 
     72        #self.__dict__['dispersion'] = self.dispersion 
     73        #self.__dict__['log'] = self.log 
     74        model_state = {'params': self.params, 'dispersion': self.dispersion, 'log': self.log} 
     75         
     76        return self.__dict__, model_state 
     77         
     78    def __setstate__(self, state): 
     79        """ create object from pickled state """ 
     80         
     81        self.__dict__, model_state = state 
     82        self.params = model_state['params'] 
     83        self.dispersion = model_state['dispersion'] 
     84        self.log = model_state['log'] 
     85         
    6786    
    6887    def run(self, x = 0.0): 
Note: See TracChangeset for help on using the changeset viewer.