Changeset 24415e9 in sasview


Ignore:
Timestamp:
Apr 9, 2009 6:00:13 PM (16 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:
87fbc60
Parents:
56e1202
Message:

set initial value for model multplication parameters

Location:
sansmodels/src/sans/models
Files:
2 edited

Legend:

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

    rdb39b2a r24415e9  
    7474        for name , value in self.model1.params.iteritems(): 
    7575            self.params[name]= value 
     76            if name in self.model2.getParamList(): 
     77                self.model2.setParam(name, value) 
    7678             
    7779        for name , value in self.model2.params.iteritems(): 
     
    98100            @param value: value of the parameter 
    99101        """ 
    100         self._setParamHelper( name, value) 
     102         
    101103        if name in self.model1.getParamList(): 
    102104            self.model1.setParam( name, value) 
     
    104106        if name in self.model2.getParamList(): 
    105107            self.model2.setParam( name, value)  
    106          
     108        
     109        self._setParamHelper( name, value) 
    107110         
    108111    def _setParamHelper(self, name, value): 
     
    150153            @return: (DAB value) 
    151154        """ 
     155        
    152156        return self.model1.run(x)* self.model2.run(x) 
    153157    
  • sansmodels/src/sans/models/test/utest_modelmultiplication.py

    r8cfdd5e r24415e9  
    2828    fixed=['radius.width'] 
    2929     
    30      
     30    def test_multiplication_radius(self): 
     31        """ test multiplication model""" 
     32        from sans.models.MultiplicationModel import MultiplicationModel 
     33        from sans.models.SphereModel import SphereModel 
     34        from sans.models.HayterMSAStructure import HayterMSAStructure 
     35        my_sphere = SphereModel() 
     36        my_struct = HayterMSAStructure() 
     37        model1  =  MultiplicationModel(my_sphere,my_struct) 
     38        self.assertEquals(model1.getParam("radius"), 
     39                          my_struct.getParam("radius"), 
     40                          my_sphere.getParam("radius")) 
     41        model2 = SphereModel() 
     42        x= 2 
     43 
     44        model1.setParam("radius", 60) 
     45        self.assertEqual(model1.getParam("radius"), 60) 
     46        a = model1.run(x) 
     47        self.assertEqual(a, 2.5723183020756634e-006) 
     48        model1.setParam("radius", 70) 
     49        b = model1.run(x) 
     50        self.assertNotEqual(a, b) 
     51        model1.setParam("radius", 60) 
     52        c =  model1.run(x) 
     53        self.assertEqual(c, 2.5723183020756634e-006) 
     54        self.assertEqual(a, c) 
     55         
     56         
     57         
     58         
    3159    def test_multiplication(self): 
    3260        """ test multiplication model""" 
Note: See TracChangeset for help on using the changeset viewer.