Ignore:
Timestamp:
Jun 10, 2008 11:27:07 AM (16 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:
38fc601
Parents:
06290c8
Message:

Modified 2D non-shape models to be the same as 1D when not defined otherwise

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/test/utest_nonshape.py

    r6b8399b ra55fac1  
    4242        self.model.setParam('rg', 1.0) 
    4343         
    44         value = self._func(2.0, 1.0, 1.0)*self._func(2.0, 1.0, 2.0) 
    45         self.assertEqual(self.model.runXY([0.0,0.0]), 2.0*2.0) 
     44        #value = self._func(2.0, 1.0, 1.0)*self._func(2.0, 1.0, 2.0) 
     45        value = self._func(2.0, 1.0, math.sqrt(5.0)) 
     46        #self.assertEqual(self.model.runXY([0.0,0.0]), 2.0*2.0) 
     47        self.assertEqual(self.model.runXY([0.0,0.0]), 2.0) 
    4648        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
    4749         
     
    5557        phi = math.atan2(y, x) 
    5658         
    57         value = self._func(2.0, 1.0, x)*self._func(2.0, 1.0, y) 
     59        #value = self._func(2.0, 1.0, x)*self._func(2.0, 1.0, y) 
     60        value = self._func(2.0, 1.0, r) 
    5861         
    5962        #self.assertEqual(self.model.run([r, phi]), value) 
     
    8386         
    8487    def test2D(self): 
    85         value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 
    86         self.assertEqual(self.model.runXY([1.0,2.0]), value) 
    87          
    88     def test2Dphi(self): 
    89         x = 1.0 
    90         y = 2.0 
    91         r = math.sqrt(x**2 + y**2) 
    92         phi = math.atan2(y, x) 
    93          
    94         value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 
     88        #value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 
     89        value = self._func(2.0, math.sqrt(5.0)) 
     90        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
     91         
     92    def test2Dphi(self): 
     93        x = 1.0 
     94        y = 2.0 
     95        r = math.sqrt(x**2 + y**2) 
     96        phi = math.atan2(y, x) 
     97         
     98        #value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 
     99        value = self._func(2.0, r) 
    95100        self.assertAlmostEquals(self.model.run([r, phi]), value,1) 
    96101         
     
    127132         
    128133    def test2D(self): 
    129         value = self._func(50.0, 1.0, 0.001, 1.0)*self._func(50.0, 1.0, 0.001, 2.0) 
     134        #value = self._func(50.0, 1.0, 0.001, 1.0)*self._func(50.0, 1.0, 0.001, 2.0) 
     135        value = self._func(50.0, 1.0, 0.001, math.sqrt(5.0)) 
    130136        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
    131137         
     
    172178        self.model.setParam('background', 1.0) 
    173179         
    174         value = self._func(100.0, 50.0, 1.0, 1.0)*self._func(100.0, 50.0, 1.0, 2.0)     
     180        #value = self._func(100.0, 50.0, 1.0, 1.0)*self._func(100.0, 50.0, 1.0, 2.0)     
     181        value = self._func(100.0, 50.0, 1.0, math.sqrt(5.0))   
    175182        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
    176183         
     
    220227         
    221228    def test2D(self): 
    222         value = self._func(self.scale, self.length, self.back, 1.0)*self._func(self.scale, self.length, self.back, 2.0)     
     229        #value = self._func(self.scale, self.length, self.back, 1.0)*self._func(self.scale, self.length, self.back, 2.0)     
     230        value = self._func(self.scale, self.length, self.back, math.sqrt(5.0)) 
    223231        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
    224232         
     
    272280        self.model.setParam('background', 1.0) 
    273281         
    274         value = self._func(math.exp(-6), 4.0, 1.0, 1.0)\ 
    275         *self._func(math.exp(-6), 4.0, 1.0, 2.0)     
     282        #value = self._func(math.exp(-6), 4.0, 1.0, 1.0)\ 
     283        #*self._func(math.exp(-6), 4.0, 1.0, 2.0)     
     284        value = self._func(math.exp(-6), 4.0, 1.0, math.sqrt(5.0)) 
    276285         
    277286        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
     
    332341        self.model.setParam('scale', 0.1) 
    333342        self.model.setParam('background', 0.1) 
    334         value = self._func(0.1,-30.0,5000.0,0.1, 1.0)\ 
    335         *self._func(0.1,-30.0,5000.0,0.1, 2.0)     
     343        #value = self._func(0.1,-30.0,5000.0,0.1, 1.0)\ 
     344        #*self._func(0.1,-30.0,5000.0,0.1, 2.0)     
     345        value = self._func(0.1,-30.0,5000.0,0.1, math.sqrt(5.0)) 
    336346         
    337347        self.assertEqual(self.model.runXY([1.0,2.0]), value) 
     
    348358        phi = math.atan2(y, x) 
    349359         
    350         value = self._func(0.1,-30.0,5000.0,0.1, x)\ 
    351         *self._func(0.1,-30.0,5000.0,0.1, y) 
     360        #value = self._func(0.1,-30.0,5000.0,0.1, x)\ 
     361        #*self._func(0.1,-30.0,5000.0,0.1, y) 
     362        value = self._func(0.1,-30.0,5000.0,0.1, r) 
    352363        self.assertAlmostEquals(self.model.run([r, phi]), value,1) 
    353364         
     
    415426          
    416427    def test2D(self): 
    417         self.assertAlmostEquals(self.model.runXY([1.0,2.0]), self._func(1.0)*self._func(2.0), 8) 
    418          
    419     def test2Dphi(self): 
    420  
    421         x = 1.0 
    422         y = 2.0 
    423         r = math.sqrt(x**2 + y**2) 
    424         phi = math.atan2(y, x) 
    425          
    426         self.assertAlmostEquals(self.model.run([r, phi]), self._func(x)*self._func(y), 8) 
     428        #self.assertAlmostEquals(self.model.runXY([1.0,2.0]), self._func(1.0)*self._func(2.0), 8) 
     429        self.assertAlmostEquals(self.model.runXY([1.0,2.0]), self._func(math.sqrt(1.0+2.0**2)), 8) 
     430         
     431    def test2Dphi(self): 
     432 
     433        x = 1.0 
     434        y = 2.0 
     435        r = math.sqrt(x**2 + y**2) 
     436        phi = math.atan2(y, x) 
     437         
     438        self.assertAlmostEquals(self.model.run([r, phi]), self._func(r), 8) 
    427439         
    428440class TestFractalModel(unittest.TestCase): 
     
    493505        iq_y = self._func(y) 
    494506         
    495         self.assertEqual(self.model.run([r, phi]), iq_x*iq_y) 
    496         self.assertEqual(self.model.runXY([x,y]), iq_x*iq_y) 
     507        #self.assertEqual(self.model.run([r, phi]), iq_x*iq_y) 
     508        self.assertEqual(self.model.run([r, phi]), self.model.run(r)) 
     509        #self.assertEqual(self.model.runXY([x,y]), iq_x*iq_y) 
     510        self.assertEqual(self.model.runXY([x,y]), self.model.run(r)) 
    497511         
    498512if __name__ == '__main__': 
Note: See TracChangeset for help on using the changeset viewer.