Changeset 5650ebf in sasview for sansmodels/src/sans/models


Ignore:
Timestamp:
Nov 26, 2010 7:23:44 PM (14 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:
02879ea
Parents:
07c4599
Message:

able pickle for model c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_models/modelTemplate.txt

    r35aface r5650ebf  
    2828from sans_extension.c_models import [CPYTHONCLASS] 
    2929import copy     
    30      
     30 
     31def create_[PYTHONCLASS](): 
     32    obj = [PYTHONCLASS]() 
     33    #[CPYTHONCLASS].__init__(obj) is called by [PYTHONCLASS] constructor 
     34    return obj 
     35 
    3136class [PYTHONCLASS]([CPYTHONCLASS], BaseComponent): 
    3237    """  
     
    4348        # Initialize BaseComponent first, then sphere 
    4449        BaseComponent.__init__(self) 
     50        #apply([CPYTHONCLASS].__init__, (self,))  
    4551        [CPYTHONCLASS].__init__(self) 
    4652         
     
    5460        self.fixed=[FIXED] 
    5561         
    56         ## non-fittable parameters 
    57         self.non_fittable=[NON_FITTABLE_PARAMS] 
    58          
    5962        ## parameters with orientation 
    6063        self.orientation_params =[ORIENTATION_PARAMS] 
    6164    
     65    def __reduce_ex__(self, proto): 
     66        """ 
     67        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of  
     68        c model. 
     69        """ 
     70        return (create_[PYTHONCLASS],tuple()) 
     71         
    6272    def clone(self): 
    6373        """ Return a identical copy of self """ 
    6474        return self._clone([PYTHONCLASS]())    
    65          
    66     def __getstate__(self): 
    67         """ 
    68         return object state for pickling and copying 
    69         """ 
    70         model_state = {'params': self.params, 'dispersion': self.dispersion, 'log': self.log} 
    71          
    72         return self.__dict__, model_state 
    73          
    74     def __setstate__(self, state): 
    75         """ 
    76         create object from pickled state 
    77          
    78         :param state: the state of the current model 
    79          
    80         """ 
    81          
    82         self.__dict__, model_state = state 
    83         self.params = model_state['params'] 
    84         self.dispersion = model_state['dispersion'] 
    85         self.log = model_state['log'] 
    8675         
    8776    
Note: See TracChangeset for help on using the changeset viewer.