source:
sasview/test/sascalculator/test/utest_slit_length_calculator.py
@
3a473ef
Last change on this file since 3a473ef was 3a473ef, checked in by Piotr Rozyczko <rozyczko@…>, 6 years ago | |
---|---|
|
|
File size: 1.0 KB |
Rev | Line | |
---|---|---|
[959eb01] | 1 | """ |
2 | Unit tests for slit_length_calculator | |
3 | """ | |
4 | ||
[3a473ef] | 5 | import os.path |
[959eb01] | 6 | import unittest |
7 | from sas.sascalc.dataloader.readers.ascii_reader import Reader | |
[b09095a] | 8 | from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator \ |
9 | as calculator | |
[959eb01] | 10 | |
11 | ||
[3a473ef] | 12 | def find(filename): |
13 | return os.path.join(os.path.dirname(__file__), filename) | |
14 | ||
15 | ||
[b09095a] | 16 | class 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 | ||
38 | if __name__ == '__main__': | |
39 | unittest.main() | |
40 |
Note: See TracBrowser
for help on using the repository browser.