source: sasview/DataLoader/test/utest_invariant.py @ 255306e

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 255306e was 4026380, checked in by Mathieu Doucet <doucetm@…>, 15 years ago

dataloader: improved invariant

  • Property mode set to 100644
File size: 2.0 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 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       
61if __name__ == '__main__':
62    unittest.main()
Note: See TracBrowser for help on using the repository browser.