source: sasview/test/sascalculator/test/utest_slit_length_calculator.py @ 3a473ef

ESS_GUIESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 3a473ef was 3a473ef, checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago

Manual update of test/ directory with changes on master - SASVIEW-996

  • Property mode set to 100644
File size: 1.0 KB
Line 
1"""
2    Unit tests for slit_length_calculator
3"""
4
5import os.path
6import unittest
7from sas.sascalc.dataloader.readers.ascii_reader import Reader
8from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator \
9    as calculator
10
11
12def find(filename):
13    return os.path.join(os.path.dirname(__file__), filename)
14
15
16class SlitCalculator(unittest.TestCase):
17   
18    def setUp(self):
19       
20        self.reader = Reader()
21       
22    def test_slit_length_calculation(self):
23        """
24            Test slit_length_calculator"
25        """
26        list = self.reader.read(find("beam profile.DAT"))
27        self.assertTrue(len(list) == 1)
28        f = list[0]
29        cal = calculator()
30        cal.set_data(f.x,f.y)
31        slit_length = cal.calculate_slit_length()
32       
33        # The value "5.5858" was obtained by manual calculation.
34        # It turns out our slit length is FWHM/2
35        self.assertAlmostEqual(slit_length, 5.5858/2, 3)
36       
37       
38if __name__ == '__main__':
39    unittest.main()
40   
Note: See TracBrowser for help on using the repository browser.