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