Changeset f98961f in sasview for sansrealspace/src/realspace/test


Ignore:
Timestamp:
Sep 28, 2007 10:48:09 AM (17 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:
3c75696
Parents:
1b0707e1
Message:

Updated run() and runXY() to be compatible with the rest of the models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansrealspace/src/realspace/test/utest_oriented.py

    r1b0707e1 rf98961f  
    254254        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 ) 
    255255 
     256class TestRunMethods(unittest.TestCase): 
     257    """ Tests run methods for oriented (2D) systems """ 
     258 
     259    def setUp(self): 
     260        """ Set up ellipsoid """ 
     261        from sans.models.EllipsoidModel import EllipsoidModel 
     262         
     263        radius_a = 10 
     264        radius_b = 15 
     265        density = 1 
     266         
     267        self.ana = EllipsoidModel() 
     268        self.ana.setParam('scale', 1.0) 
     269        self.ana.setParam('contrast', 1.0) 
     270        self.ana.setParam('background', 0.0) 
     271        self.ana.setParam('radius_a', radius_a) 
     272        self.ana.setParam('radius_b', radius_b) 
     273 
     274        
     275        canvas = VolumeCanvas.VolumeCanvas() 
     276        canvas.setParam('lores_density', density) 
     277        self.handle = canvas.add('ellipsoid') 
     278        canvas.setParam('%s.radius_x' % self.handle, radius_a) 
     279        canvas.setParam('%s.radius_y' % self.handle, radius_b) 
     280        canvas.setParam('%s.radius_z' % self.handle, radius_b) 
     281        canvas.setParam('scale' , 1.0) 
     282        canvas.setParam('%s.contrast' % self.handle, 1.0) 
     283        canvas.setParam('background' , 0.0) 
     284        self.canvas = canvas      
     285            
     286        self.ana.setParam('axis_theta', 1.57) 
     287        self.ana.setParam('axis_phi', 0) 
     288         
     289        self.canvas.setParam('%s.orientation' % self.handle, [0,0,0]) 
     290         
     291 
     292    def testRunXY_List(self): 
     293        """ Testing ellipsoid along X """ 
     294        ana_val = self.ana.runXY([0.1, 0.2]) 
     295        sim_val = self.canvas.runXY([0.1, 0.2]) 
     296        #print ana_val, sim_val, sim_val/ana_val 
     297         
     298        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 ) 
     299 
     300    def testRunXY_float(self): 
     301        """ Testing ellipsoid along X """ 
     302        ana_val = self.ana.runXY(0.1) 
     303        sim_val = self.canvas.runXY(0.1) 
     304        #print ana_val, sim_val, sim_val/ana_val 
     305         
     306        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 ) 
     307 
     308    def testRun_float(self): 
     309        """ Testing ellipsoid along X """ 
     310        ana_val = self.ana.run(0.1) 
     311        sim_val = self.canvas.run(0.1) 
     312        #print ana_val, sim_val, sim_val/ana_val 
     313         
     314        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 ) 
     315 
     316    def testRun_list(self): 
     317        """ Testing ellipsoid along X """ 
     318        ana_val = self.ana.run([0.1, 33.0]) 
     319        sim_val = self.canvas.run([0.1, 33.0]) 
     320        #print ana_val, sim_val, sim_val/ana_val 
     321         
     322        self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 ) 
     323 
     324           
     325 
     326 
    256327if __name__ == '__main__': 
    257328    unittest.main()         
Note: See TracChangeset for help on using the changeset viewer.