source: sasview/sansmodels/test/utest_models_new1_3.py @ 077207b

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 077207b was 18e250c, checked in by Gervaise Alina <gervyh@…>, 13 years ago

move test to sansmodels top level

  • Property mode set to 100644
File size: 2.8 KB
Line 
1"""
2    Unit tests for specific models II
3"""
4
5import unittest, time, math
6     
7class TestFuzzySphere(unittest.TestCase):
8    """ Unit tests for fuzzysphere model """
9   
10    def setUp(self):
11        from sans.models.FuzzySphereModel import FuzzySphereModel
12        self.comp = FuzzySphereModel()
13       
14    def test1D(self):
15        """ Test 1D model for a fuzzysphere """
16        self.assertAlmostEqual(self.comp.run(1), 0.001, 3)
17       
18    def test1D_2(self):
19        """ Test 2D model for a fuzzysphere """
20        self.assertAlmostEqual(self.comp.run([1, 1.3]), 0.001, 3)
21       
22class TestPolyGaussCoil(unittest.TestCase):
23    """ Unit tests for PolyGaussCoil """
24   
25    def setUp(self):
26        from sans.models.Poly_GaussCoil import Poly_GaussCoil
27        self.comp = Poly_GaussCoil()
28       
29    def test1D(self):
30        """ Test 1D model for a PolyGaussCoil """
31        self.assertAlmostEqual(self.comp.run(0.107000453), 0.0688476, 4)
32       
33    def test1D_2(self):
34        """ Test 2D model for a PolyGaussCoil """
35        self.assertAlmostEqual(self.comp.run([0.107000453, 0.2]), 0.0688476, 4)
36               
37class TestCoreFourShellModel(unittest.TestCase):
38    """ Unit tests for CoreFourShellModel """
39   
40    def setUp(self):
41        from sans.models.CoreFourShellModel import CoreFourShellModel
42        self.comp = CoreFourShellModel()
43       
44    def test1D(self):
45        """ Test 1D model for a CoreFourShellModel """
46        print "sldsolv",self.comp.getParam("sld_solv")
47        self.assertAlmostEqual(self.comp.run(0.001), 3318.19548, 4)
48       
49    def test1D_2(self):
50        """ Test 2D model for a CoreFourShellModel """
51        self.assertAlmostEqual(self.comp.run([0.001, 0.2]), 3318.19548, 4)
52
53class TestFractal(unittest.TestCase):
54    """ Unit tests for Fractal model """
55   
56    def setUp(self):
57        from sans.models.FractalModel import FractalModel
58        self.comp = FractalModel()
59       
60    def test1D(self):
61        """ Test 1D model for a Fractal """
62        self.assertAlmostEqual(self.comp.run(0.001), 39.288146, 4)
63       
64    def test1D_2(self):
65        """ Test 2D model for a Fractal """
66        self.assertAlmostEqual(self.comp.run([0.001, 1]), 39.288146, 4)
67                               
68class TestLamella(unittest.TestCase):
69    """ Unit tests for Lamella model """
70   
71    def setUp(self):
72        from sans.models.LamellarModel import LamellarModel
73        self.comp = LamellarModel()
74       
75    def test1D(self):
76        """ Test 1D model for a Lamellar """
77        self.assertAlmostEqual(self.comp.run(1.0), 5.6387e-5, 4)
78       
79    def test1D_2(self):
80        """ Test 2D model for a Lamellar """
81        self.assertAlmostEqual(self.comp.run([1.0, 1.3]), 5.6387e-5, 4)
82               
83       
84
85if __name__ == '__main__':
86    unittest.main()
Note: See TracBrowser for help on using the repository browser.