Changeset c1e865a in sasview for sansmodels/src/sans/models/test/utest_model_calculate_ER.py
- Timestamp:
- Sep 11, 2009 8:40:17 AM (15 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:
- 1affe64
- Parents:
- f9bf661
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/test/utest_model_calculate_ER.py
rca90d54 rc1e865a 1 1 """ 2 Unit tests for specific models 2 Unit tests for calculate_ER of specific models 3 @author: JHJ Cho / UTK 3 4 """ 4 5 5 import unittest, time, math 6 7 # Disable "missing docstring" complaint 8 # pylint: disable-msg=C0111 9 # Disable "too many methods" complaint 10 # pylint: disable-msg=R0904 11 # Disable "could be a function" complaint 12 # pylint: disable-msg=R0201 13 6 import unittest, time, math, numpy 14 7 15 8 … … 136 129 self.diam.setParam("radius", 3000) 137 130 self.diam.setParam("length",80) 138 self.assertAlmostEqual(self.comp.calculate_ER(), self.diam.run(0.1)/2) 139 131 self.assertAlmostEqual(self.comp.calculate_ER(), self.diam.run(0.1)/2) 132 133 class TestEllipticalCylinder(unittest.TestCase): 134 """ Unit tests for calculate_ER (EllipticalCylindermodel) """ 135 136 def setUp(self): 137 from sans.models.EllipticalCylinderModel import EllipticalCylinderModel 138 from sans.models.DiamCylFunc import DiamCylFunc 139 self.comp = EllipticalCylinderModel() 140 self.diam = DiamCylFunc() 141 142 def test(self): 143 """ Test 1D model for a EllipticalCylinder """ 144 self.comp.setParam("r_minor", 20) 145 self.comp.setParam("r_ratio",1.5) 146 self.comp.setParam("length",400) 147 r_value = math.sqrt(20*20*1.5) 148 self.diam.setParam("radius", r_value) 149 self.diam.setParam("length",400) 150 self.assertAlmostEqual(self.comp.calculate_ER(), self.diam.run(0.1)/2) 151 152 class TestParallelepiped(unittest.TestCase): 153 """ Unit tests for calculate_ER (Parallelepipedmodel) """ 154 155 def setUp(self): 156 from sans.models.ParallelepipedModel import ParallelepipedModel 157 from sans.models.DiamCylFunc import DiamCylFunc 158 self.comp = ParallelepipedModel() 159 self.diam = DiamCylFunc() 160 161 def test(self): 162 """ Test 1D model for a Parallelepiped """ 163 self.comp.setParam("short_a", 35) 164 self.comp.setParam("short_b", 75) 165 self.comp.setParam("long_c",400) 166 r_value = math.sqrt(35*75/math.pi) 167 self.diam.setParam("radius", r_value) 168 self.diam.setParam("length",400) 169 self.assertAlmostEqual(self.comp.calculate_ER(), self.diam.run(0.1)/2) 170 140 171 class TestEllipsoid(unittest.TestCase): 141 172 """ Unit tests for calculate_ER (Ellipsoid model) """ … … 170 201 self.diam.setParam("radius_a", 20) 171 202 self.diam.setParam("radius_b",400) 172 self.assertAlmostEqual(self.comp.calculate_ER(), self.diam.run(0.1)/2) 203 self.assertAlmostEqual(self.comp.calculate_ER(), self.diam.run(0.1)/2) 204 205 class TestLamellar(unittest.TestCase): 206 """ Unit tests for calculate_ER (Lamellarmodel)""" 207 208 def setUp(self): 209 from sans.models.LamellarModel import LamellarModel 210 self.comp = LamellarModel() 211 212 def test(self): 213 """ Test 1D model for a Lamellar """ 214 #No finite number should return from Lamellar models. 215 self.assertFalse(numpy.isfinite(self.comp.calculate_ER())) 216 217 class TestGuinier(unittest.TestCase): 218 """ Unit tests for calculate_ER (Guinier model) """ 219 220 def setUp(self): 221 from sans.models.GuinierModel import GuinierModel 222 self.comp = GuinierModel() 223 224 def test(self): 225 """ Test 1D model for Guinier """ 226 #calculate_ER() is not implemented for pure python model functions 227 self.assertEqual(self.comp.calculate_ER(), NotImplemented) 228 173 229 if __name__ == '__main__': 174 230 unittest.main()
Note: See TracChangeset
for help on using the changeset viewer.