ESS_GUI
Last change
on this file 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 | |
---|
5 | import os.path |
---|
6 | import unittest |
---|
7 | from sas.sascalc.dataloader.readers.ascii_reader import Reader |
---|
8 | from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator \ |
---|
9 | as calculator |
---|
10 | |
---|
11 | |
---|
12 | def find(filename): |
---|
13 | return os.path.join(os.path.dirname(__file__), filename) |
---|
14 | |
---|
15 | |
---|
16 | class 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 | |
---|
38 | if __name__ == '__main__': |
---|
39 | unittest.main() |
---|
40 | |
---|
Note: See
TracBrowser
for help on using the repository browser.