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