1 | """ |
---|
2 | Unit tests for data manipulations |
---|
3 | @author Gervaise Alina: unittest imcoplete so far |
---|
4 | """ |
---|
5 | |
---|
6 | |
---|
7 | import unittest |
---|
8 | import numpy, math |
---|
9 | from DataLoader.loader import Loader |
---|
10 | from DataLoader.data_info import Data1D, Data2D |
---|
11 | from DataLoader.invariant import InvariantCalculator |
---|
12 | |
---|
13 | |
---|
14 | class InvariantTest(unittest.TestCase): |
---|
15 | |
---|
16 | def setUp(self): |
---|
17 | #Data with no slit smear information |
---|
18 | data0 = Loader().load("PolySpheres.txt") |
---|
19 | self.I0 = InvariantCalculator( data=data0) |
---|
20 | |
---|
21 | # data with smear info |
---|
22 | list = Loader().load("latex_smeared.xml") |
---|
23 | data1= list[0] |
---|
24 | self.I1= InvariantCalculator( data= data1) |
---|
25 | |
---|
26 | data2= list[1] |
---|
27 | self.I2= InvariantCalculator( data= data2) |
---|
28 | |
---|
29 | def test_invariant(self): |
---|
30 | """ test the invariant value for data with no slit smear""" |
---|
31 | self.assertAlmostEquals(self.I0.q_star, 7.48959e-5) |
---|
32 | self.assertTrue(self.I1.q_star>0) |
---|
33 | self.assertTrue(self.I2.q_star>0) |
---|
34 | |
---|
35 | def test_computation(self): |
---|
36 | """ |
---|
37 | Test identity smearing |
---|
38 | """ |
---|
39 | vol = self.I0.get_volume_fraction(contrast=2.6e-6) |
---|
40 | surface = self.I0.get_surface(contrast=2.6e-6, porod_const=20) |
---|
41 | |
---|
42 | # TODO: Need to test output values |
---|
43 | #self.assertAlmostEquals(vol, 0) |
---|
44 | #self.assertAlmostEquals(surface, 0) |
---|
45 | vol = self.I1.get_volume_fraction(contrast=5.3e-6) |
---|
46 | surface = self.I1.get_surface(contrast=5.3e-6, porod_const=20) |
---|
47 | |
---|
48 | # TODO: Need to test output values |
---|
49 | #self.assertAlmostEquals(vol, 0) |
---|
50 | #self.assertAlmostEquals(surface, 0) |
---|
51 | |
---|
52 | vol = self.I2.get_volume_fraction(contrast=5.3e-6) |
---|
53 | surface = self.I2.get_surface(contrast=5.3e-6, porod_const=20) |
---|
54 | |
---|
55 | # TODO: Need to test output values |
---|
56 | self.assertAlmostEquals(vol, 0) |
---|
57 | self.assertAlmostEquals(surface, 0) |
---|
58 | |
---|
59 | |
---|
60 | |
---|
61 | if __name__ == '__main__': |
---|
62 | unittest.main() |
---|