class TestPorod(unittest.TestCase): """ Unit tests for Porod function F(x) = C/Q**4 The model has one parameter: C """ def _func(self, c, x): return c/(x**4) def setUp(self): from sas.models.PorodModel import PorodModel self.model= PorodModel() self.model.setParam('scale', 2.0) def test1D(self): value = self._func(2.0, 3.0) self.assertEqual(self.model.run(3.0), value) self.assertEqual(self.model.runXY(3.0), value) def test2D(self): #value = self._func(2.0, 1.0)*self._func(2.0, 2.0) value = self._func(2.0, math.sqrt(5.0)) self.assertEqual(self.model.runXY([1.0,2.0]), value) def test2Dphi(self): x = 1.0 y = 2.0 r = math.sqrt(x**2 + y**2) phi = math.atan2(y, x) #value = self._func(2.0, 1.0)*self._func(2.0, 2.0) value = self._func(2.0, r) self.assertAlmostEquals(self.model.run([r, phi]), value,1)
def setUp(self): from sas.models.PorodModel import PorodModel self.model= PorodModel() self.model.setParam('scale', 2.0)