Changeset f1e0c1eb in sasview for sansmodels/test
- Timestamp:
- Jul 26, 2012 8:53:20 AM (12 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:
- 7fdb332
- Parents:
- 32ea318
- Location:
- sansmodels/test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/test/utest_nonshape.py
r18e250c rf1e0c1eb 248 248 value = self._func(self.scale, self.length, self.back, x)*self._func(self.scale, self.length, self.back, y) 249 249 self.assertAlmostEquals(self.model.run([x, y]), value,1) 250 250 251 251 252 class TestPowerLaw(unittest.TestCase): 252 253 """ … … 521 522 if __name__ == '__main__': 522 523 unittest.main() 524 -
sansmodels/test/utest_other_models.py
r279e371 rf1e0c1eb 1233 1233 """ Test DABModel at the critical point""" 1234 1234 self.assert_(numpy.isfinite(self.comp.run(0.0))) 1235 1236 class TestStarPolymer(unittest.TestCase): 1237 """ Unit tests for StarPolymer""" 1238 1239 def setUp(self): 1240 from sans.models.StarPolymer import StarPolymer 1241 self.comp = StarPolymer() 1242 self.comp.setParam('arms',3.0) 1243 self.comp.setParam('scale',5.0) 1244 self.comp.setParam('background',1.0) 1245 self.comp.setParam('R2',100.0) 1246 1247 1248 def test1D(self): 1249 """ Test 1D model for a StarPolymer""" 1250 # our variables 1251 q = 0.001 1252 rg = 100.0 1253 f = 3.0 1254 bkg = 1.0 1255 scale = 5.0 1256 1257 # equation set up 1258 u = rg * q * q 1259 v = u * u * f / (3*f - 2) 1260 p = 2 / (f * v * v) 1261 temp = v - 1 + math.exp(-v) 1262 temp += (f - 1)/2 * math.pow(1 - math.exp(-v), 2) 1263 p *= (temp * scale) 1264 p += bkg 1265 1266 self.assertAlmostEquals(self.comp.run(q), p, 5) 1267 1268 def test1D_2(self): 1269 """ Test 2D model for a StarPolymer""" 1270 qx = 0.001 1271 qy = 1.3 1272 q = math.sqrt(qx*qx + qy*qy) 1273 rg = 100.0 1274 f = 3.0 1275 bkg = 1.0 1276 scale = 5.0 1277 1278 # equation set up 1279 u = rg * q * q 1280 v = u * u * f / (3*f - 2) 1281 p = 2 / (f * v * v) 1282 temp = v - 1 + math.exp(-v) 1283 temp += (f - 1)/2 * math.pow(1 - math.exp(-v), 2) 1284 p *= (temp * scale) 1285 p += bkg 1286 1287 self.assertAlmostEqual(self.comp.runXY([0.001, 1.3]), p, 5) 1235 1288 1236 1289
Note: See TracChangeset
for help on using the changeset viewer.