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.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change
on this file since e71440c was
1b162dfa,
checked in by Mathieu Doucet <doucetm@…>, 16 years ago
|
Working on refactoring models (not done)
|
-
Property mode set to
100644
|
File size:
1.7 KB
|
Rev | Line | |
---|
[1b162dfa] | 1 | """ |
---|
| 2 | Unit tests for dispersion functionality of |
---|
| 3 | C++ model classes |
---|
| 4 | """ |
---|
| 5 | |
---|
| 6 | import unittest, math, numpy |
---|
| 7 | |
---|
| 8 | class TestModel(object): |
---|
| 9 | """ |
---|
| 10 | An old-style model |
---|
| 11 | """ |
---|
| 12 | def __init__(self): |
---|
| 13 | ## Parameter dictionary |
---|
| 14 | self.params = {} |
---|
| 15 | self.params['scale'] = 0.05 |
---|
| 16 | |
---|
| 17 | ## Parameter details [units, min, max] |
---|
| 18 | self.details = {} |
---|
| 19 | self.details['scale'] = ['', None, None] |
---|
| 20 | |
---|
| 21 | def run(self, x): |
---|
| 22 | return self.params['scale']*x |
---|
| 23 | |
---|
| 24 | from BaseModel import BaseModel |
---|
| 25 | class NewTestModel(BaseModel): |
---|
| 26 | scale = ParameterProperty('scale') |
---|
| 27 | |
---|
| 28 | def __init__(self): |
---|
| 29 | BaseModel.__init__(self) |
---|
| 30 | self.parameters = {} |
---|
| 31 | self.parameters['scale'] = Parameter('scale', 4.0) |
---|
| 32 | |
---|
| 33 | def run(self, x): |
---|
| 34 | return self.scale*x |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | class TestBaseModel(unittest.TestCase): |
---|
| 38 | """ |
---|
| 39 | Testing C++ Cylinder model |
---|
| 40 | """ |
---|
| 41 | def setUp(self): |
---|
| 42 | from sans.models.BaseModel import BaseModel |
---|
| 43 | self.model = BaseModel() |
---|
| 44 | |
---|
| 45 | |
---|
| 46 | def test_removed_attrs(self): |
---|
| 47 | def setop(): |
---|
| 48 | print self.model.operateOn |
---|
| 49 | self.assertRaises(AttributeError, setop) |
---|
| 50 | def setother(): |
---|
| 51 | print self.model.other |
---|
| 52 | self.assertRaises(AttributeError, setother) |
---|
| 53 | |
---|
| 54 | class TestAdaptor(unittest.TestCase): |
---|
| 55 | """ |
---|
| 56 | Testing C++ Cylinder model |
---|
| 57 | """ |
---|
| 58 | def setUp(self): |
---|
| 59 | from sans.models.NewCylinderModel import NewCylinderModel |
---|
| 60 | self.model = NewCylinderModel() |
---|
| 61 | |
---|
| 62 | |
---|
| 63 | def test_setparam(self): |
---|
| 64 | pass |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | if __name__ == '__main__': |
---|
| 69 | unittest.main() |
---|
| 70 | |
---|
Note: See
TracBrowser
for help on using the repository browser.