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 iwth no slit smear information |
---|
18 | data0= Loader().load("PolySpheres.txt") |
---|
19 | self.I0 = InvariantCalculator( data= data0,contrast=2.6e-6, pConst=20) |
---|
20 | # data with smear info |
---|
21 | list = Loader().load("latex_smeared.xml") |
---|
22 | data1= list[0] |
---|
23 | self.I1= InvariantCalculator( data= data1,contrast=5.3e-6, pConst=20) |
---|
24 | data2= list[1] |
---|
25 | self.I2= InvariantCalculator( data= data2,contrast=5.3e-6, pConst=20) |
---|
26 | |
---|
27 | def testInvariant(self): |
---|
28 | """ test the invariant value for data with no slit smear""" |
---|
29 | self.assertAlmostEquals(self.I0.q_star, 7.48959e-5) |
---|
30 | |
---|
31 | |
---|
32 | def test_Computation(self): |
---|
33 | """ |
---|
34 | Test identity smearing |
---|
35 | """ |
---|
36 | # compute invariant with smear information |
---|
37 | print "invariant initialized only with data:", self.I1 |
---|
38 | print "invariant q_star",self.I1.q_star |
---|
39 | print "invariant volume",self.I1.volume |
---|
40 | print "Invariant surface",self.I1.surface |
---|
41 | print |
---|
42 | print "invariant initialized __call__:", self.I1 |
---|
43 | print "invariant q_star",self.I1.q_star |
---|
44 | print "invariant volume",self.I1.volume |
---|
45 | print "Invariant surface",self.I1.surface |
---|
46 | print |
---|
47 | # compute invariant with smear information |
---|
48 | print "invariant initialize with data, contrast,pConst:", self.I2 |
---|
49 | print "invariant q_star",self.I2.q_star |
---|
50 | print "invariant volume",self.I2.volume |
---|
51 | print "Invariant surface",self.I2.surface |
---|
52 | print |
---|
53 | |
---|
54 | |
---|
55 | if __name__ == '__main__': |
---|
56 | unittest.main() |
---|