Changeset 8809e48 in sasview for sansmodels/src/sans/models/test
- Timestamp:
- Oct 15, 2008 11:01:06 AM (16 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 00353b4
- Parents:
- ae60f86
- Location:
- sansmodels/src/sans/models/test
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/test/utest_dispersity.py
rae60f86 r8809e48 47 47 self.assertAlmostEqual(self.model.run(0.001), 4723.32213339, 3) 48 48 self.assertAlmostEqual(self.model.runXY([0.001,0.001]), 4743.56, 2) 49 50 def test_clone(self): 51 from sans.models.dispersion_models import GaussianDispersion 52 disp = GaussianDispersion() 53 self.model.set_dispersion('radius', disp) 54 self.model.dispersion['radius']['width'] = 5.0 55 self.model.dispersion['radius']['npts'] = 100 56 self.model.setParam('scale', 10.0) 57 58 new_model = self.model.clone() 59 self.assertAlmostEqual(new_model.run(0.001), 4723.32213339, 3) 60 self.assertAlmostEqual(new_model.runXY([0.001,0.001]), 4743.56, 2) 49 61 50 62 def test_gaussian_zero(self): -
sansmodels/src/sans/models/test/utest_newstylemodels.py
rae60f86 r8809e48 22 22 return self.params['scale']*x 23 23 24 from sans.models.BaseModel import BaseModel, ParameterProperty24 from sans.models.BaseModel import BaseModel, Parameter, ParameterProperty 25 25 class NewTestModel(BaseModel): 26 26 scale = ParameterProperty('scale') … … 31 31 self.parameters['scale'] = Parameter('scale', 4.0) 32 32 33 def run(self, x): 33 34 def runXY(self, x): 34 35 return self.scale*x 35 36 36 37 class TestBogusModel(unittest.TestCase): 38 def setUp(self): 39 self.model = NewTestModel() 40 41 def test_call(self): 42 self.assertEqual(self.model(1), 4.0) 43 self.model.scale = 1.0 44 self.assertEqual(self.model(1), 1.0) 45 self.model.setParam('scale',2.0) 46 self.assertEqual(self.model(1), 2.0) 47 self.assertEqual(self.model.getParam('scale'), 2.0) 48 37 49 class TestBaseModel(unittest.TestCase): 38 50 """ … … 66 78 67 79 68 print self.model.parameters69 80 70 81 print self.model(0.001) 82 print self.model.parameters['length'] 71 83 self.model.setParam("length", 250.0) 84 self.assertEquals(self.model.getParam("length"), 250.0) 85 86 print self.model.parameters['length'] 72 87 print self.model(0.001) 73 88 -
sansmodels/src/sans/models/test/utest_nonshape.py
ra55fac1 r8809e48 130 130 # An exceptio is raised 131 131 self.assertRaises(ZeroDivisionError, self.model.run, 0.0) 132 133 def test1D_clone(self): 134 value = self._func(50.0, 1.0, 10.0, 2.0) 135 self.model.setParam('background', 10.0) 136 clone = self.model.clone() 137 self.assertEqual(clone.run(2.0), value) 138 self.assertEqual(clone.runXY(2.0), value) 139 140 # User enter zero as a value of x 141 # An exceptio is raised 142 self.assertRaises(ZeroDivisionError, clone.run, 0.0) 132 143 133 144 def test2D(self):
Note: See TracChangeset
for help on using the changeset viewer.