magnetic_scattrelease-4.2.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change
on this file since f53d684 was
f53d684,
checked in by Paul Kienzle <pkienzle@…>, 6 years ago
|
Make tests work from any directory and functional without special runner script (#124)
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | """ |
---|
2 | Unit tests for DistExplorer class |
---|
3 | """ |
---|
4 | |
---|
5 | import os.path |
---|
6 | import unittest, math, numpy |
---|
7 | from utest_invertor import load |
---|
8 | from sas.sascalc.pr.invertor import Invertor |
---|
9 | from sas.sascalc.pr.distance_explorer import DistExplorer |
---|
10 | |
---|
11 | |
---|
12 | def find(filename): |
---|
13 | return os.path.join(os.path.dirname(__file__), filename) |
---|
14 | |
---|
15 | |
---|
16 | class TestExplorer(unittest.TestCase): |
---|
17 | |
---|
18 | def setUp(self): |
---|
19 | self.invertor = Invertor() |
---|
20 | x, y, err = load(find('sphere_80.txt')) |
---|
21 | |
---|
22 | # Choose the right d_max... |
---|
23 | self.invertor.d_max = 160.0 |
---|
24 | # Set a small alpha |
---|
25 | self.invertor.alpha = .0007 |
---|
26 | # Set data |
---|
27 | self.invertor.x = x |
---|
28 | self.invertor.y = y |
---|
29 | self.invertor.err = err |
---|
30 | self.invertor.nfunc = 15 |
---|
31 | |
---|
32 | self.explo = DistExplorer(self.invertor) |
---|
33 | |
---|
34 | def test_exploration(self): |
---|
35 | results = self.explo(120, 200, 25) |
---|
36 | self.assertEqual(len(results.errors), 0) |
---|
37 | self.assertEqual(len(results.chi2), 25) |
---|
38 | |
---|
39 | if __name__ == '__main__': |
---|
40 | unittest.main() |
---|
Note: See
TracBrowser
for help on using the repository browser.