Changeset 579ba85 in sasview for DataLoader/test
- Timestamp:
- Aug 29, 2008 3:56:50 PM (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:
- 442f42f
- Parents:
- 4c00964
- Location:
- DataLoader/test
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
DataLoader/test/cansas1d.xml
r4c00964 r579ba85 8 8 <SASentry> 9 9 <Title>Test title</Title> 10 <Run >1234</Run>10 <Run name='run name'>1234</Run> 11 11 <SASdata> 12 12 <Idata> … … 19 19 </Idata> 20 20 <Idata> 21 <Q unit="1/A">0.0 2</Q>22 <I unit="1/cm">100 0</I>23 <Idev unit="1/cm"> 3</Idev>24 <Qdev unit="1/A">0.0 1</Qdev>21 <Q unit="1/A">0.03</Q> 22 <I unit="1/cm">1001</I> 23 <Idev unit="1/cm">4</Idev> 24 <Qdev unit="1/A">0.02</Qdev> 25 25 <Qmean unit="1/A"><!-- Qmean is optional --></Qmean> 26 26 <Shadowfactor><!-- Shadowfactor is optional --></Shadowfactor> 27 27 </Idata> 28 28 </SASdata> 29 <SASsample >29 <SASsample name='my sample'> 30 30 <ID>SI600-new-long</ID> 31 31 <thickness unit="mm">1.03</thickness> … … 53 53 <SASsource name="source name"> 54 54 <radiation>neutron</radiation> 55 <beam_size >55 <beam_size name='bm'> 56 56 <x unit="mm">12.00</x> 57 <y unit="mm">1 2.00</y>57 <y unit="mm">13.00</y> 58 58 </beam_size> 59 59 <beam_shape>disc</beam_shape> … … 74 74 </aperture> 75 75 <aperture name="sample" type="radius"> 76 <size >76 <size name='size name'> 77 77 <x unit="mm">1</x> 78 78 </size> -
DataLoader/test/utest_abs_reader.py
r4c00964 r579ba85 135 135 136 136 def test_checkdata(self): 137 self.assertEqual(self.data.filename, "cansas1d.xml") 138 self._checkdata() 139 140 def _checkdata(self): 137 141 """ 138 142 Check the data content to see whether … … 142 146 tests won't pass 143 147 """ 144 self.assertEqual(self.data.filename, "cansas1d.xml") 145 self.assertEqual(self.data.run, "1234") 148 149 self.assertEqual(self.data.run[0], "1234") 150 151 # Data 152 self.assertEqual(len(self.data.x), 2) 153 self.assertEqual(self.data.x_unit, '1/A') 154 self.assertEqual(self.data.y_unit, '1/cm') 155 self.assertEqual(self.data.x[0], 0.02) 156 self.assertEqual(self.data.y[0], 1000) 157 self.assertEqual(self.data.dx[0], 0.01) 158 self.assertEqual(self.data.dy[0], 3) 159 self.assertEqual(self.data.x[1], 0.03) 160 self.assertEqual(self.data.y[1], 1001) 161 self.assertEqual(self.data.dx[1], 0.02) 162 self.assertEqual(self.data.dy[1], 4) 163 self.assertEqual(self.data.run_name['1234'], 'run name') 164 self.assertEqual(self.data.title, "Test title") 146 165 147 166 # Sample info 148 167 self.assertEqual(self.data.sample.ID, "SI600-new-long") 168 self.assertEqual(self.data.sample.name, "my sample") 149 169 self.assertEqual(self.data.sample.thickness_unit, 'mm') 150 170 self.assertEqual(self.data.sample.thickness, 1.03) … … 167 187 168 188 # Instrument info 169 self.assertEqual(self.data.instrument, " TESTinstrument")189 self.assertEqual(self.data.instrument, "canSAS instrument") 170 190 171 191 # Source … … 173 193 174 194 self.assertEqual(self.data.source.beam_size_unit, "mm") 195 self.assertEqual(self.data.source.beam_size_name, "bm") 175 196 self.assertEqual(self.data.source.beam_size.x, 12) 176 self.assertEqual(self.data.source.beam_size.y, 1 2)197 self.assertEqual(self.data.source.beam_size.y, 13) 177 198 178 199 self.assertEqual(self.data.source.beam_shape, "disc") … … 192 213 _found2 = False 193 214 self.assertEqual(self.data.collimation[0].length, 123.) 215 self.assertEqual(self.data.collimation[0].name, 'test coll name') 194 216 195 217 for item in self.data.collimation[0].aperture: … … 198 220 199 221 if item.size.x==50 \ 200 and item.distance==11000.: 222 and item.distance==11000.0 \ 223 and item.name=='source' \ 224 and item.type=='radius': 201 225 _found1 = True 202 elif item.size.x==1.0: 226 elif item.size.x==1.0 \ 227 and item.name=='sample' \ 228 and item.type=='radius': 203 229 _found2 = True 204 230 … … 209 235 # Detector 210 236 self.assertEqual(self.data.detector[0].name, "fictional hybrid") 211 self.assertEqual(self.data.detector[0].distance_unit, "m ")212 self.assertEqual(self.data.detector[0].distance, 4 .150)237 self.assertEqual(self.data.detector[0].distance_unit, "mm") 238 self.assertEqual(self.data.detector[0].distance, 4150) 213 239 214 240 self.assertEqual(self.data.detector[0].orientation_unit, "degree") … … 218 244 219 245 self.assertEqual(self.data.detector[0].offset_unit, "m") 220 self.assertEqual(self.data.detector[0].offset.x, .0 1)221 self.assertEqual(self.data.detector[0].offset.y, .0 2)246 self.assertEqual(self.data.detector[0].offset.x, .001) 247 self.assertEqual(self.data.detector[0].offset.y, .002) 222 248 self.assertEqual(self.data.detector[0].offset.z, None) 223 249 … … 233 259 234 260 # Process 261 _found_term1 = False 262 _found_term2 = False 263 for item in self.data.process: 264 self.assertTrue(item.name in ['NCNR-IGOR', 'spol']) 265 self.assertTrue(item.date in ['04-Sep-2007 18:35:02', 266 '03-SEP-2006 11:42:47']) 267 for t in item.term: 268 if t['name']=="ABS:DSTAND" \ 269 and t['unit']=='mm' \ 270 and float(t['value'])==1.0: 271 _found_term2 = True 272 elif t['name']=="radialstep" \ 273 and t['unit']=='mm' \ 274 and float(t['value'])==10.0: 275 _found_term1 = True 276 277 if _found_term1==False or _found_term2==False: 278 raise RuntimeError, "Could not find all process terms %s %s" % (_found_term1, _found_term2) 279 235 280 236 281 … … 243 288 dy = numpy.ones(5) 244 289 245 d = Loader().load("jan08002.ABS") 246 #d = Data1D(x, y, dy) 247 r.write("write_test.xml", d) 290 filename = "write_test.xml" 291 r.write(filename, self.data) 292 self.data = Loader().load(filename) 293 self.assertEqual(self.data.filename, filename) 294 self._checkdata() 295 248 296 249 297
Note: See TracChangeset
for help on using the changeset viewer.