Changeset 8677607 in sasview for sansmodels/src/sans/models/test


Ignore:
Timestamp:
Aug 3, 2011 10:58:07 AM (13 years ago)
Author:
Jae Cho <jhjcho@…>
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:
e52eeea
Parents:
67ae937
Message:

added flexcylellipCrosssection model utest

File:
1 edited

Legend:

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

    r64f0c5d r8677607  
    378378    #    self.assert_(numpy.isfinite(self.comp.run(0.0))) 
    379379   
     380class TestFlexCylEllipXModel(unittest.TestCase): 
     381    """ Unit tests for FlexCylEllipXModel""" 
     382     
     383    def setUp(self): 
     384        from sans.models.FlexCylEllipXModel import FlexCylEllipXModel 
     385        self.comp = FlexCylEllipXModel() 
     386        #Give initial value to model 
     387        self.comp.setParam("scale", 1.0) 
     388        self.comp.setParam("sldSolv",6.3e-6 ) 
     389        self.comp.setParam("sldCyl",1e-6 ) 
     390        self.comp.setParam("kuhn_length",100) 
     391        self.comp.setParam("length", 1000) 
     392        self.comp.setParam("radius",20) 
     393        self.comp.setParam("background", 0.0001) 
     394        self.comp.setParam("axis_ratio", 1.0) 
     395         
     396        self.x = numpy.array([0.4, 1.3]) 
     397        self.y = numpy.array([0.5, 1.57]) 
     398        self.x_array = self.comp.evalDistribution(self.x) 
     399        self.y_array = self.comp.evalDistribution(self.y) 
     400         
     401        qx_prime = numpy.reshape(self.x, [1,len(self.x)]) 
     402        qy_prime = numpy.reshape(self.y, [len(self.y),1]) 
     403        self.xy_matrix = self.comp.evalDistribution([self.x, self.y]) 
     404         
     405        self.q = 0.001 
     406        self.phi= math.pi/2 
     407        self.qx= self.q*math.cos(self.phi) 
     408        self.qy= self.q*math.sin(self.phi) 
     409         
     410    def test1D(self): 
     411        """ Test 1D model for FlexCylEllipXModel""" 
     412        self.assertAlmostEqual(self.comp.run(0.001), 3509.22, 1) 
     413         
     414    def test1D_2(self): 
     415        """ Test 2D model for FlexCylEllipXModel""" 
     416        self.assertAlmostEqual(self.comp.run([self.q, self.phi]),  
     417                              self.comp.runXY([self.qx, self.qy]),1)  
     418    def testEval_1D(self): 
     419        """ Test 1D model for FlexCylEllipXModel with evalDistribution""" 
     420        self.assertEquals(self.comp.run(0.4),self.x_array[0]) 
     421        self.assertEquals(self.comp.run(1.3),self.x_array[1]) 
     422         
     423    def testEval_2D(self): 
     424        """ Test 2D model for FlexCylEllipXModel with evalDistribution""" 
     425        self.assertAlmostEquals(self.comp.runXY([0.4, 0.5]),self.xy_matrix[0],8) 
     426        self.assertAlmostEquals(self.comp.runXY([1.3,1.57]),self.xy_matrix[1], 8) 
     427               
    380428               
    381429class TestStackedDisksModel(unittest.TestCase): 
Note: See TracChangeset for help on using the changeset viewer.