source: sasview/DataLoader/test/utest_invariant.py @ 1ea3488

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 1ea3488 was ac13512, checked in by Gervaise Alina <gervyh@…>, 15 years ago

working on invariant

  • Property mode set to 100644
File size: 1.9 KB
Line 
1"""
2    Unit tests for data manipulations
3    @author Gervaise Alina: unittest imcoplete so far
4"""
5
6
7import unittest
8import numpy, math
9from DataLoader.loader import  Loader
10from DataLoader.data_info import Data1D, Data2D
11from DataLoader.invariant import InvariantCalculator
12
13
14class 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       
55if __name__ == '__main__':
56    unittest.main()
Note: See TracBrowser for help on using the repository browser.