Changeset 5401f2a in sasview for sansmodels


Ignore:
Timestamp:
Aug 17, 2012 5:59:34 AM (12 years ago)
Author:
Kieran Campbell <kieranrcampbell@…>
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:
c329f4d
Parents:
d8e3f7c
Message:

Unit test for star polymer model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/test/utest_models.py

    r0abf7bf r5401f2a  
    9696        self.assertAlmostEqual(self.gauss.run([math.sqrt(8.0), math.pi/4.0]), 2.0*2.0*value*value, 5) 
    9797         
     98class TestStarPolymer(unittest.TestCase): 
     99    """Unit tests for Star Polymer""" 
     100    def setUp(self): 
     101        from sans.models.StarPolymer import StarPolymer 
     102        self.star = StarPolymer() 
     103 
     104    def test1D(self): 
     105        self.star.setParam('scale', 3.0) 
     106        self.star.setParam('arms', 5.0) 
     107        self.star.setParam('R2', 100.0) 
     108        self.star.setParam('background', 1.0) 
     109        self.assertAlmostEqual(self.star.run(0.01), 3.9998999827681025) 
     110 
     111    def test2D(self): 
     112        x = 0.009539392014169456 
     113        y = 0.003 
     114        # together these have modulus 1 
     115        self.star.setParam('scale', 3.0) 
     116        self.star.setParam('arms', 5.0) 
     117        self.star.setParam('R2', 100.0) 
     118        self.star.setParam('background', 1.0) 
     119        self.assertAlmostEqual(self.star.runXY([x, y]), 3.9998999827681025) 
     120 
     121    def test2Dphi(self): 
     122        self.star.setParam('scale', 3.0) 
     123        self.star.setParam('arms', 5.0) 
     124        self.star.setParam('R2', 100.0) 
     125        self.star.setParam('background', 1.0) 
     126         
     127        self.assertAlmostEqual(self.star.run([0.01, math.pi/4.0]), 3.9998999827681025) 
     128 
     129 
     130 
    98131class TestLorentzian(unittest.TestCase): 
    99132    """Unit tests for Lorentzian function""" 
     
    101134    def setUp(self): 
    102135        from sans.models.Lorentzian import Lorentzian 
    103         self.lor= Lorentzian() 
     136        self.lor  
     137 
     138= Lorentzian() 
    104139         
    105140    def test1D(self): 
Note: See TracChangeset for help on using the changeset viewer.