source: sasview/test/sascalculator/test/utest_slit_length_calculator.py @ b09095a

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.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since b09095a was b09095a, checked in by krzywon, 7 years ago

Refactor ASCII reader to use FileReader? class.

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