1 | """ |
---|
2 | Unit tests for specific models II |
---|
3 | """ |
---|
4 | |
---|
5 | import unittest, time, math |
---|
6 | |
---|
7 | class 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 | |
---|
22 | class 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 | |
---|
37 | class 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 | |
---|
53 | class 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 | |
---|
68 | class 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 | |
---|
85 | if __name__ == '__main__': |
---|
86 | unittest.main() |
---|