Changeset a55fac1 in sasview for sansmodels/src
- Timestamp:
- Jun 10, 2008 11:27:07 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:
- 38fc601
- Parents:
- 06290c8
- Location:
- sansmodels/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/release_notes.txt
r3de85b8 ra55fac1 2 2 ============= 3 3 4 SANS Models version 0.4. 04 SANS Models version 0.4.1 5 5 6 6 Package name: sans.models 7 7 8 1- What's New in Version 0.4.0 8 1- What's New in Version 0.4.1 9 - Release date: 6/9/2008 10 - Modified non-shape models so that the 2D output is the 1D output for the length of Q 11 12 Version 0.4.0 9 13 - Release date: 4/15/2008 10 14 - Added shape-independent models. … … 13 17 - Release date: 2/14/2008 14 18 - Added models to be used in magnetic analysis. 15 16 19 17 20 -
sansmodels/src/sans/models/BEPolyelectrolyte.py
r3db3895 ra55fac1 94 94 """ 95 95 if x.__class__.__name__ == 'list': 96 return self._BEPoly(x[0] *math.cos(x[1]))*self._BEPoly(x[0]*math.sin(x[1]))96 return self._BEPoly(x[0]) 97 97 elif x.__class__.__name__ == 'tuple': 98 98 raise ValueError, "Tuples are not allowed as input to BaseComponent models" … … 106 106 """ 107 107 if x.__class__.__name__ == 'list': 108 return self._BEPoly(x[0])*self._BEPoly(x[1]) 108 q = math.sqrt(x[0]**2 + x[1]**2) 109 return self._BEPoly(q) 109 110 elif x.__class__.__name__ == 'tuple': 110 111 raise ValueError, "Tuples are not allowed as input to BaseComponent models" -
sansmodels/src/sans/models/DABModel.py
r3db3895 ra55fac1 57 57 """ 58 58 if x.__class__.__name__ == 'list': 59 return self._DAB(x[0] *math.cos(x[1]))*self._DAB(x[0]*math.sin(x[1]))59 return self._DAB(x[0]) 60 60 elif x.__class__.__name__ == 'tuple': 61 61 raise ValueError, "Tuples are not allowed as input to BaseComponent models" … … 69 69 """ 70 70 if x.__class__.__name__ == 'list': 71 return self._DAB(x[0])*self._DAB(x[1]) 71 q = math.sqrt(x[0]**2 + x[1]**2) 72 return self._DAB(q) 72 73 elif x.__class__.__name__ == 'tuple': 73 74 raise ValueError, "Tuples are not allowed as input to BaseComponent models" -
sansmodels/src/sans/models/DebyeModel.py
rf629e346 ra55fac1 64 64 """ 65 65 if x.__class__.__name__ == 'list': 66 return self._debye(x[0] *math.cos(x[1]))*self._debye(x[0]*math.sin(x[1]))66 return self._debye(x[0]) 67 67 elif x.__class__.__name__ == 'tuple': 68 68 raise ValueError, "Tuples are not allowed as input to BaseComponent models" … … 76 76 """ 77 77 if x.__class__.__name__ == 'list': 78 return self._debye(x[0])*self._debye(x[1]) 78 q = math.sqrt(x[0]**2 + x[1]**2) 79 return self._debye(q) 79 80 elif x.__class__.__name__ == 'tuple': 80 81 raise ValueError, "Tuples are not allowed as input to BaseComponent models" -
sansmodels/src/sans/models/FractalModel.py
r36948c92 ra55fac1 99 99 # Take absolute value of Q, since this model is really meant to 100 100 # be defined in 1D for a given length of Q 101 qx = math.fabs(x[0]*math.cos(x[1]))102 qy = math.fabs(x[0]*math.sin(x[1]))101 #qx = math.fabs(x[0]*math.cos(x[1])) 102 #qy = math.fabs(x[0]*math.sin(x[1])) 103 103 104 return self._Fractal( qx)*self._Fractal(qy)104 return self._Fractal(math.fabs(x[0])) 105 105 elif x.__class__.__name__ == 'tuple': 106 106 raise ValueError, "Tuples are not allowed as input to BaseComponent models" … … 114 114 """ 115 115 if x.__class__.__name__ == 'list': 116 return self._Fractal(x[0])*self._Fractal(x[1]) 116 q = math.sqrt(x[0]**2 + x[1]**2) 117 return self._Fractal(q) 117 118 elif x.__class__.__name__ == 'tuple': 118 119 raise ValueError, "Tuples are not allowed as input to BaseComponent models" -
sansmodels/src/sans/models/GuinierModel.py
r3db3895 ra55fac1 48 48 """ 49 49 if x.__class__.__name__ == 'list': 50 return self._guinier(x[0] *math.cos(x[1]))*self._guinier(x[0]*math.sin(x[1]))50 return self._guinier(x[0]) 51 51 elif x.__class__.__name__ == 'tuple': 52 52 raise ValueError, "Tuples are not allowed as input to BaseComponent models" … … 60 60 """ 61 61 if x.__class__.__name__ == 'list': 62 return self._guinier(x[0])*self._guinier(x[1]) 62 q = math.sqrt(x[0]**2 + x[1]**2) 63 return self._guinier(q) 63 64 elif x.__class__.__name__ == 'tuple': 64 65 raise ValueError, "Tuples are not allowed as input to BaseComponent models" -
sansmodels/src/sans/models/LorentzModel.py
r3db3895 ra55fac1 57 57 """ 58 58 if x.__class__.__name__ == 'list': 59 return self._lorentz(x[0] *math.cos(x[1]))*self._lorentz(x[0]*math.sin(x[1]))59 return self._lorentz(x[0]) 60 60 elif x.__class__.__name__ == 'tuple': 61 61 raise ValueError, "Tuples are not allowed as input to BaseComponent models" … … 69 69 """ 70 70 if x.__class__.__name__ == 'list': 71 return self._lorentz(x[0])*self._lorentz(x[1]) 71 q = math.sqrt(x[0]**2 + x[1]**2) 72 return self._lorentz(q) 72 73 elif x.__class__.__name__ == 'tuple': 73 74 raise ValueError, "Tuples are not allowed as input to BaseComponent models" -
sansmodels/src/sans/models/PorodModel.py
r36948c92 ra55fac1 45 45 """ 46 46 if x.__class__.__name__ == 'list': 47 return self._porod(x[0] *math.cos(x[1]))*self._porod(x[0]*math.sin(x[1]))47 return self._porod(x[0]) 48 48 elif x.__class__.__name__ == 'tuple': 49 49 raise ValueError, "Tuples are not allowed as input to BaseComponent models" … … 57 57 """ 58 58 if x.__class__.__name__ == 'list': 59 return self._porod(x[0])*self._porod(x[1]) 59 q = math.sqrt(x[0]**2 + x[1]**2) 60 return self._porod(q) 60 61 elif x.__class__.__name__ == 'tuple': 61 62 raise ValueError, "Tuples are not allowed as input to BaseComponent models" -
sansmodels/src/sans/models/PowerLawModel.py
r36948c92 ra55fac1 61 61 # Take absolute value of Q, since this model is really meant to 62 62 # be defined in 1D for a given length of Q 63 qx = math.fabs(x[0]*math.cos(x[1]))64 qy = math.fabs(x[0]*math.sin(x[1]))65 return self._PowerLaw( qx)*self._PowerLaw(qy)63 #qx = math.fabs(x[0]*math.cos(x[1])) 64 #qy = math.fabs(x[0]*math.sin(x[1])) 65 return self._PowerLaw(math.fabs(x[0])) 66 66 elif x.__class__.__name__ == 'tuple': 67 67 raise ValueError, "Tuples are not allowed as input to BaseComponent models" … … 75 75 """ 76 76 if x.__class__.__name__ == 'list': 77 return self._PowerLaw(x[0])*self._PowerLaw(x[1]) 77 q = math.sqrt(x[0]**2 + x[1]**2) 78 return self._PowerLaw(q) 78 79 elif x.__class__.__name__ == 'tuple': 79 80 raise ValueError, "Tuples are not allowed as input to BaseComponent models" -
sansmodels/src/sans/models/TeubnerStreyModel.py
rf629e346 ra55fac1 62 62 """ 63 63 if x.__class__.__name__ == 'list': 64 return self._TeubnerStrey(x[0]*math.cos(x[1]))\ 65 *self._TeubnerStrey(x[0]*math.sin(x[1])) 64 return self._TeubnerStrey(x[0]) 66 65 elif x.__class__.__name__ == 'tuple': 67 66 raise ValueError, "Tuples are not allowed as input to BaseComponent models" … … 75 74 """ 76 75 if x.__class__.__name__ == 'list': 77 return self._TeubnerStrey(x[0])*self._TeubnerStrey(x[1]) 76 q = math.sqrt(x[0]**2 + x[1]**2) 77 return self._TeubnerStrey(q) 78 78 elif x.__class__.__name__ == 'tuple': 79 79 raise ValueError, "Tuples are not allowed as input to BaseComponent models" -
sansmodels/src/sans/models/test/utest_nonshape.py
r6b8399b ra55fac1 42 42 self.model.setParam('rg', 1.0) 43 43 44 value = self._func(2.0, 1.0, 1.0)*self._func(2.0, 1.0, 2.0) 45 self.assertEqual(self.model.runXY([0.0,0.0]), 2.0*2.0) 44 #value = self._func(2.0, 1.0, 1.0)*self._func(2.0, 1.0, 2.0) 45 value = self._func(2.0, 1.0, math.sqrt(5.0)) 46 #self.assertEqual(self.model.runXY([0.0,0.0]), 2.0*2.0) 47 self.assertEqual(self.model.runXY([0.0,0.0]), 2.0) 46 48 self.assertEqual(self.model.runXY([1.0,2.0]), value) 47 49 … … 55 57 phi = math.atan2(y, x) 56 58 57 value = self._func(2.0, 1.0, x)*self._func(2.0, 1.0, y) 59 #value = self._func(2.0, 1.0, x)*self._func(2.0, 1.0, y) 60 value = self._func(2.0, 1.0, r) 58 61 59 62 #self.assertEqual(self.model.run([r, phi]), value) … … 83 86 84 87 def test2D(self): 85 value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 86 self.assertEqual(self.model.runXY([1.0,2.0]), value) 87 88 def test2Dphi(self): 89 x = 1.0 90 y = 2.0 91 r = math.sqrt(x**2 + y**2) 92 phi = math.atan2(y, x) 93 94 value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 88 #value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 89 value = self._func(2.0, math.sqrt(5.0)) 90 self.assertEqual(self.model.runXY([1.0,2.0]), value) 91 92 def test2Dphi(self): 93 x = 1.0 94 y = 2.0 95 r = math.sqrt(x**2 + y**2) 96 phi = math.atan2(y, x) 97 98 #value = self._func(2.0, 1.0)*self._func(2.0, 2.0) 99 value = self._func(2.0, r) 95 100 self.assertAlmostEquals(self.model.run([r, phi]), value,1) 96 101 … … 127 132 128 133 def test2D(self): 129 value = self._func(50.0, 1.0, 0.001, 1.0)*self._func(50.0, 1.0, 0.001, 2.0) 134 #value = self._func(50.0, 1.0, 0.001, 1.0)*self._func(50.0, 1.0, 0.001, 2.0) 135 value = self._func(50.0, 1.0, 0.001, math.sqrt(5.0)) 130 136 self.assertEqual(self.model.runXY([1.0,2.0]), value) 131 137 … … 172 178 self.model.setParam('background', 1.0) 173 179 174 value = self._func(100.0, 50.0, 1.0, 1.0)*self._func(100.0, 50.0, 1.0, 2.0) 180 #value = self._func(100.0, 50.0, 1.0, 1.0)*self._func(100.0, 50.0, 1.0, 2.0) 181 value = self._func(100.0, 50.0, 1.0, math.sqrt(5.0)) 175 182 self.assertEqual(self.model.runXY([1.0,2.0]), value) 176 183 … … 220 227 221 228 def test2D(self): 222 value = self._func(self.scale, self.length, self.back, 1.0)*self._func(self.scale, self.length, self.back, 2.0) 229 #value = self._func(self.scale, self.length, self.back, 1.0)*self._func(self.scale, self.length, self.back, 2.0) 230 value = self._func(self.scale, self.length, self.back, math.sqrt(5.0)) 223 231 self.assertEqual(self.model.runXY([1.0,2.0]), value) 224 232 … … 272 280 self.model.setParam('background', 1.0) 273 281 274 value = self._func(math.exp(-6), 4.0, 1.0, 1.0)\ 275 *self._func(math.exp(-6), 4.0, 1.0, 2.0) 282 #value = self._func(math.exp(-6), 4.0, 1.0, 1.0)\ 283 #*self._func(math.exp(-6), 4.0, 1.0, 2.0) 284 value = self._func(math.exp(-6), 4.0, 1.0, math.sqrt(5.0)) 276 285 277 286 self.assertEqual(self.model.runXY([1.0,2.0]), value) … … 332 341 self.model.setParam('scale', 0.1) 333 342 self.model.setParam('background', 0.1) 334 value = self._func(0.1,-30.0,5000.0,0.1, 1.0)\ 335 *self._func(0.1,-30.0,5000.0,0.1, 2.0) 343 #value = self._func(0.1,-30.0,5000.0,0.1, 1.0)\ 344 #*self._func(0.1,-30.0,5000.0,0.1, 2.0) 345 value = self._func(0.1,-30.0,5000.0,0.1, math.sqrt(5.0)) 336 346 337 347 self.assertEqual(self.model.runXY([1.0,2.0]), value) … … 348 358 phi = math.atan2(y, x) 349 359 350 value = self._func(0.1,-30.0,5000.0,0.1, x)\ 351 *self._func(0.1,-30.0,5000.0,0.1, y) 360 #value = self._func(0.1,-30.0,5000.0,0.1, x)\ 361 #*self._func(0.1,-30.0,5000.0,0.1, y) 362 value = self._func(0.1,-30.0,5000.0,0.1, r) 352 363 self.assertAlmostEquals(self.model.run([r, phi]), value,1) 353 364 … … 415 426 416 427 def test2D(self): 417 self.assertAlmostEquals(self.model.runXY([1.0,2.0]), self._func(1.0)*self._func(2.0), 8) 418 419 def test2Dphi(self): 420 421 x = 1.0 422 y = 2.0 423 r = math.sqrt(x**2 + y**2) 424 phi = math.atan2(y, x) 425 426 self.assertAlmostEquals(self.model.run([r, phi]), self._func(x)*self._func(y), 8) 428 #self.assertAlmostEquals(self.model.runXY([1.0,2.0]), self._func(1.0)*self._func(2.0), 8) 429 self.assertAlmostEquals(self.model.runXY([1.0,2.0]), self._func(math.sqrt(1.0+2.0**2)), 8) 430 431 def test2Dphi(self): 432 433 x = 1.0 434 y = 2.0 435 r = math.sqrt(x**2 + y**2) 436 phi = math.atan2(y, x) 437 438 self.assertAlmostEquals(self.model.run([r, phi]), self._func(r), 8) 427 439 428 440 class TestFractalModel(unittest.TestCase): … … 493 505 iq_y = self._func(y) 494 506 495 self.assertEqual(self.model.run([r, phi]), iq_x*iq_y) 496 self.assertEqual(self.model.runXY([x,y]), iq_x*iq_y) 507 #self.assertEqual(self.model.run([r, phi]), iq_x*iq_y) 508 self.assertEqual(self.model.run([r, phi]), self.model.run(r)) 509 #self.assertEqual(self.model.runXY([x,y]), iq_x*iq_y) 510 self.assertEqual(self.model.runXY([x,y]), self.model.run(r)) 497 511 498 512 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.