Changeset 3c75696 in sasview for sansrealspace/src/realspace/test
- Timestamp:
- Oct 18, 2007 1:36:17 PM (17 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:
- 8c050c1
- Parents:
- f98961f
- Location:
- sansrealspace/src/realspace/test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansrealspace/src/realspace/test/simulation_stimuli.py
rba1d1e9 r3c75696 160 160 except: 161 161 report.log = "GetIq: bad value for Iq "+str(value) 162 163 report.trace = "I(q) = %g" % value 164 return canvas, report 165 166 class GetIq2DStimulus(Stimulus): 167 """Calculate I(q)""" 168 169 frequency = 1.0 170 171 def __call__(self, canvas): 172 report = generator.StimulusReport(tag=self.name) 173 174 # Check that a float is returned 175 # Validation testing will be done elsewhere 176 value = canvas.getIq2D(0.01,0.01) 177 178 # Check that it is in the list of objects 179 try: 180 float(value) 181 report.passed = 1 182 except: 183 report.log = "GetIq2D: bad value for Iq "+str(value) 162 184 163 185 report.trace = "I(q) = %g" % value -
sansrealspace/src/realspace/test/utest_oriented.py
rf98961f r3c75696 59 59 sim_val = self.model.getIq2D(0.1, 0.1) 60 60 self.assert_( math.fabs(sim_val/ana_val-1.0)<0.1 ) 61 62 class TestCylinderAddObject(unittest.TestCase): 63 """ Tests for oriented (2D) systems """ 64 65 def setUp(self): 66 """ Set up cylinder model """ 67 from sans.models.CylinderModel import CylinderModel 68 radius = 5 69 length = 40 70 density = 20 71 72 # Analytical model 73 self.ana = CylinderModel() 74 self.ana.setParam('scale', 1.0) 75 self.ana.setParam('contrast', 1.0) 76 self.ana.setParam('background', 0.0) 77 self.ana.setParam('radius', radius) 78 self.ana.setParam('length', length) 79 80 # Simulation model 81 self.model = VolumeCanvas.VolumeCanvas() 82 cyl = VolumeCanvas.CylinderDescriptor() 83 self.handle = self.model.addObject(cyl) 84 self.model.setParam('lores_density', density) 85 self.model.setParam('%s.radius' % self.handle, radius) 86 self.model.setParam('%s.length' % self.handle, length) 87 self.model.setParam('scale' , 1.0) 88 self.model.setParam('%s.contrast' % self.handle, 1.0) 89 self.model.setParam('background' , 0.0) 90 91 def testalongY(self): 92 """ Testing cylinder along Y axis """ 93 self.ana.setParam('cyl_theta', math.pi/2.0) 94 self.ana.setParam('cyl_phi', math.pi/2.0) 95 96 self.model.setParam('%s.orientation' % self.handle, [0,0,0]) 97 98 ana_val = self.ana.runXY([0.1, 0.2]) 99 sim_val = self.model.getIq2D(0.1, 0.2) 100 #print ana_val, sim_val, sim_val/ana_val 101 102 self.assert_( math.fabs(sim_val/ana_val-1.0)<0.05 ) 103 61 104 62 105 class TestCylinder(unittest.TestCase):
Note: See TracChangeset
for help on using the changeset viewer.