예제 #1
0
 def setUp(self):
     from sas.models.Lorentzian import Lorentzian
     self.lor = Lorentzian()
예제 #2
0
class TestLorentzian(unittest.TestCase):
    """Unit tests for Lorentzian function"""
    
    def setUp(self):
        from sas.models.Lorentzian import Lorentzian
        self.lor= Lorentzian()
        
    def test1D(self):
        self.lor.setParam('scale', 2.0)
        self.lor.setParam('center', 1.0)
        self.lor.setParam('gamma', 1.0)
        self.assertEqual(self.lor.run(1.0), 4.0/math.pi)
        value = 1/math.pi*0.5/(1+.25)
        self.assertEqual(self.lor.run(2.0), 2.0*value)
        
    def test2D(self):
        self.lor.setParam('scale', 0.5*math.pi)
        self.lor.setParam('center', 1.0)
        self.lor.setParam('gamma', 1.0)
        self.assertEqual(self.lor.run(1.0), 1.0)
        value = 0.25/(1+.25)
        self.assertEqual(self.lor.runXY([1.0,2.0]), value)
        self.assertEqual(self.lor.runXY([2.0,2.0]), value*value)
        
    def test2Dphi(self):
        self.lor.setParam('scale', 0.5*math.pi)
        self.lor.setParam('center', 1.0)
        self.lor.setParam('gamma', 1.0)
        self.assertEqual(self.lor.run(1.0), 1.0)
        value = 0.25/(1+.25)
        self.assertAlmostEqual(self.lor.run([math.sqrt(8.0), math.pi/4.0]), value*value, 5)
예제 #3
0
class TestLorentzian(unittest.TestCase):
    """Unit tests for Lorentzian function"""
    def setUp(self):
        from sas.models.Lorentzian import Lorentzian
        self.lor = Lorentzian()

    def test1D(self):
        self.lor.setParam('scale', 2.0)
        self.lor.setParam('center', 1.0)
        self.lor.setParam('gamma', 1.0)
        self.assertEqual(self.lor.run(1.0), 4.0 / math.pi)
        value = 1 / math.pi * 0.5 / (1 + .25)
        self.assertEqual(self.lor.run(2.0), 2.0 * value)

    def test2D(self):
        self.lor.setParam('scale', 0.5 * math.pi)
        self.lor.setParam('center', 1.0)
        self.lor.setParam('gamma', 1.0)
        self.assertEqual(self.lor.run(1.0), 1.0)
        value = 0.25 / (1 + .25)
        self.assertEqual(self.lor.runXY([1.0, 2.0]), value)
        self.assertEqual(self.lor.runXY([2.0, 2.0]), value * value)

    def test2Dphi(self):
        self.lor.setParam('scale', 0.5 * math.pi)
        self.lor.setParam('center', 1.0)
        self.lor.setParam('gamma', 1.0)
        self.assertEqual(self.lor.run(1.0), 1.0)
        value = 0.25 / (1 + .25)
        self.assertAlmostEqual(self.lor.run([math.sqrt(8.0), math.pi / 4.0]),
                               value * value, 5)
예제 #4
0
 def setUp(self):
     from sas.models.Lorentzian import Lorentzian
     self.lor= Lorentzian()