- Timestamp:
- Dec 24, 2013 1:32:14 PM (11 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:
- 81b524f
- Parents:
- a25d242
- Location:
- test
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
test/sansdataloader/test/cansas1d_units.xml
reda8972 r75eeb425 11 11 <SASdata> 12 12 <Idata> 13 <Q unit="1/nm">0. 002</Q>13 <Q unit="1/nm">0.2</Q> 14 14 <I unit="1/nm">0.0001</I> 15 15 <Idev unit="1/nm">.0000003</Idev> -
test/sansdataloader/test/test_log.txt
reda8972 r75eeb425 1 2013-12- 13 14:02:18,947DEBUG Inside testLoad module2 2013-12- 13 14:02:19,323INFO Danse_reader Reading MP_New.sans1 2013-12-20 15:51:09,931 DEBUG Inside testLoad module 2 2013-12-20 15:51:10,296 INFO Danse_reader Reading MP_New.sans 3 3 4 2013-12- 13 14:02:19,381INFO Danse_reader Reading P_New.sans4 2013-12-20 15:51:10,348 INFO Danse_reader Reading P_New.sans 5 5 -
test/sansdataloader/test/utest_abs_reader.py
reda8972 r75eeb425 159 159 160 160 def setUp(self): 161 self.data = Loader().load("cansas1d.xml") 162 if isinstance(self.data, list): 163 self.data = self.data[0] 161 data = Loader().load("cansas1d.xml") 162 self.data = data[0] 164 163 165 164 def test_cansas_checkdata(self): 166 print "\rtest_cansas_checkdata"167 165 self.assertEqual(self.data.filename, "cansas1d.xml") 168 166 self._checkdata() … … 212 210 213 211 self.assertEqual(self.data.sample.orientation_unit, 'degree') 214 self.assert Equal(self.data.sample.orientation.x, 22.5)215 self.assert Equal(self.data.sample.orientation.y, 0.02)212 self.assertAlmostEqual(self.data.sample.orientation.x, 22.5, 6) 213 self.assertAlmostEqual(self.data.sample.orientation.y, 0.02, 6) 216 214 217 215 self.assertEqual(self.data.sample.details[0], "http://chemtools.chem.soton.ac.uk/projects/blog/blogs.php/bit_id/2720") … … 250 248 self.assertEqual(item.size_unit,'mm') 251 249 self.assertEqual(item.distance_unit,'mm') 252 print "size.x = {0}".format(item.size.x)253 print "distance = {0}".format(item.distance)254 print "name = {0}".format(item.name)255 print "type = {0}".format(item.type)256 250 257 251 if item.size.x==50 \ … … 266 260 267 261 if _found1==False or _found2==False: 268 print item.distance269 262 raise RuntimeError, "Could not find all data %s %s" % (_found1, _found2) 270 263 … … 275 268 276 269 self.assertEqual(self.data.detector[0].orientation_unit, "degree") 277 self.assert Equal(self.data.detector[0].orientation.x, 1.0)270 self.assertAlmostEqual(self.data.detector[0].orientation.x, 1.0, 6) 278 271 self.assertEqual(self.data.detector[0].orientation.y, 0.0) 279 272 self.assertEqual(self.data.detector[0].orientation.z, 0.0) … … 318 311 319 312 def test_writer(self): 320 print "\rtest_writer"321 313 from sans.dataloader.readers.cansas_reader import Reader 322 314 r = Reader() … … 327 319 filename = "write_test.xml" 328 320 r.write(filename, self.data) 329 self.data = Loader().load(filename)[0] 321 data = Loader().load(filename) 322 self.data = data[0] 330 323 self.assertEqual(self.data.filename, filename) 331 324 self._checkdata() … … 336 329 Note that not all units are available. 337 330 """ 338 print "\rtest_units"339 331 filename = "cansas1d_units.xml" 340 self.data = Loader().load(filename) 341 if isinstance(self.data, list): 342 self.data = self.data[0] 332 data = Loader().load(filename) 333 self.data = data[0] 343 334 self.assertEqual(self.data.filename, filename) 344 335 self._checkdata() … … 349 340 Note that not all units are available. 350 341 """ 351 print "\rtest_badunits"352 342 filename = "cansas1d_badunits.xml" 353 self.data = Loader().load(filename) 354 if isinstance(self.data, list): 355 self.data = self.data[0] 343 data = Loader().load(filename) 344 self.data = data[0] 356 345 self.assertEqual(self.data.filename, filename) 357 346 # The followed should not have been loaded … … 368 357 Check slit data 369 358 """ 370 print "\rtest_slits"371 359 filename = "cansas1d_slit.xml" 372 self.data = Loader().load(filename) 373 if isinstance(self.data, list): 374 self.data = self.data[0] 360 data = Loader().load(filename) 361 self.data = data[0] 375 362 self.assertEqual(self.data.filename, filename) 376 363 self.assertEqual(self.data.run[0], "1234") … … 378 365 # Data 379 366 self.assertEqual(len(self.data.x), 2) 380 print self.data.x381 367 self.assertEqual(self.data.x_unit, '1/A') 382 368 self.assertEqual(self.data.y_unit, '1/cm') … … 392 378 self.assertEqual(self.data.dxw[1], 0.001) 393 379 self.assertEqual(self.data.dy[1], 4) 394 #self.assertEqual(self.data.run_name['1234'], 'run name')380 self.assertEqual(self.data.run_name['1234'], 'run name') 395 381 self.assertEqual(self.data.title, "Test title") 396 382 397 383 398 384 -
test/sansdataloader/test/utest_cansas.py
reda8972 r75eeb425 21 21 from lxml import etree 22 22 import xml.dom.minidom 23 _ZERO = 1e-1624 HAS_CONVERTER = True25 try:26 from data_util.nxsunit import Converter27 except:28 HAS_CONVERTER = False29 23 30 24 CANSAS_FORMAT = cansasConstants.CANSAS_FORMAT 31 25 CANSAS_NS = cansasConstants.CANSAS_NS 32 ALLOW_ALL = True33 26 34 27 class cansas_reader(unittest.TestCase): … … 48 41 self.schema_1_0 = "cansas1d_v1_0.xsd" 49 42 self.schema_1_1 = "cansas1d_v1_1.xsd" 43 50 44 51 45 def get_number_of_entries(self, dictionary, name, i): … … 56 50 name = self.get_number_of_entries(dictionary, name, i) 57 51 return name 52 58 53 59 54 def test_xml_validate(self): … … 74 69 self.assertFalse(xmlschema.validate(invalid)) 75 70 71 76 72 def test_real_xml(self): 77 73 reader = XMLreader(self.xml_valid, self.schema_1_0) … … 81 77 else: 82 78 self.assertFalse(valid) 79 83 80 84 81 def test_cansas_xml(self): 82 filename = "isis_1_1_write_test.xml" 85 83 xmlreader = XMLreader(self.isis_1_1, self.schema_1_1) 86 84 valid = xmlreader.validateXML() … … 91 89 self.assertTrue(data.title == "TK49 c10_SANS") 92 90 self.assertTrue(data.x.size == 138) 93 self.assertTrue(len(data.meta_data) == 417)91 self.assertTrue(len(data.meta_data) == 2) 94 92 self.assertTrue(data.detector[0].distance_unit == "mm") 93 reader.write(filename, data) 94 reader2 = Reader() 95 return_data = reader2.read(filename) 96 data_new = return_data 97 self.data = return_data[0] 98 self.assertTrue(self.data.x.size == 138) 99 self.assertTrue(len(self.data.meta_data) == 2) 100 self.assertTrue(self.data.detector[0].distance_unit == "mm") 101 self.assertTrue(self.data.title == "TK49 c10_SANS") 95 102 96 103 def test_entry_name_recurse(self): … … 102 109 d[new_key] = value 103 110 self.assertTrue(len(d) == 6) 111 104 112 105 113 def test_load_cansas_file(self): … … 119 127 reader7 = XMLreader(self.isis_1_1, self.schema_1_0) 120 128 self.assertFalse(reader7.validateXML()) 129 121 130 122 131 def test_old_cansas_files(self): -
test/sansdataloader/test/write_test.xml
reda8972 r75eeb425 16 16 1000.0 17 17 </I> 18 19 20 18 <Idev unit="1/cm"> 19 3.0 20 </Idev> 21 21 <Qdev unit="1/A"> 22 22 0.01 … … 30 30 1001.0 31 31 </I> 32 33 34 32 <Idev unit="1/cm"> 33 4.0 34 </Idev> 35 35 <Qdev unit="1/A"> 36 36 0.02 … … 51 51 0.0 52 52 </temperature> 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 53 <position> 54 <x unit="mm"> 55 10.0 56 </x> 57 <y unit="mm"> 58 0.0 59 </y> 60 </position> 61 <orientation> 62 <roll unit="degree"> 63 22.5 64 </roll> 65 <pitch unit="degree"> 66 0.02 67 </pitch> 68 </orientation> 69 69 <details> 70 70 http://chemtools.chem.soton.ac.uk/projects/blog/blogs.php/bit_id/2720 … … 82 82 neutron 83 83 </radiation> 84 85 86 87 88 89 90 91 84 <beam_size name="bm"> 85 <x unit="mm"> 86 12.0 87 </x> 88 <y unit="mm"> 89 13.0 90 </y> 91 </beam_size> 92 92 <beam_shape> 93 93 disc … … 117 117 </size> 118 118 <distance unit="mm"> 119 11000120 119 11000.0 120 </distance> 121 121 </aperture> 122 122 <aperture name="sample" type="radius"> 123 <size name="size name">123 <size> 124 124 <x unit="mm"> 125 125 1.0 … … 133 133 </name> 134 134 <SDD unit="mm"> 135 4150 135 4150.0 136 136 </SDD> 137 137 <offset> … … 143 143 </y> 144 144 </offset> 145 146 147 148 149 150 151 152 153 154 155 145 <orientation> 146 <roll unit="degree"> 147 1.0 148 </roll> 149 <pitch unit="degree"> 150 0.0 151 </pitch> 152 <yaw unit="degree"> 153 0.0 154 </yaw> 155 </orientation> 156 156 <beam_center> 157 157 <x unit="mm"> … … 195 195 </term> 196 196 <SASprocessnote> 197 AvA1 0.0000E+00 AsA2 1.0000E+00 XvA3 1.0526E+03 XsA4 198 5.2200E-02 XfA5 0.0000E+00 199 </SASprocessnote> 200 <SASprocessnote> 201 S... 13597 0 2.26E+02 2A 5mM 0%D2O Sbak 13594 0 1.13E+02 202 H2O Buffer 203 </SASprocessnote> 204 <SASprocessnote> 205 V... 13552 3 1.00E+00 H2O5m 197 206 198 </SASprocessnote> 207 199 </SASprocess> … … 246 238 1 247 239 </term> 248 <SASProcessnote /> 240 <SASprocessnote> 241 242 </SASprocessnote> 249 243 </SASprocess> 250 <SASnote 244 <SASnote/> 251 245 </SASentry> 252 246 </SASroot> -
test/sansguiframe/test/cansas1d.xml
r5777106 r75eeb425 49 49 50 50 </SASsample> 51 <SASinstrument name="TEST instrument">51 <SASinstrument> 52 52 <name>canSAS instrument</name> 53 53 <SASsource name="source name"> … … 85 85 4.150 86 86 </SDD> 87 <orientation> 87 <offset> 88 <x unit="mm">1</x> 89 <y unit="mm">2</y> 90 </offset> 91 <orientation> 88 92 <roll unit="degree">1.00</roll> 89 93 <pitch unit="degree">0.00</pitch> 90 94 <yaw unit="degree">0.00</yaw> 91 95 </orientation> 92 <offset>93 <x unit="mm">1</x>94 <y unit="mm">2</y>95 </offset>96 96 <beam_center> 97 97 <x unit="mm">322.64</x> … … 135 135 <term name="ABS:IZERO">230.09</term> 136 136 <term name="ABS:XSECT" unit="mm">1</term> 137 <SASprocessnote />137 <SASprocessnote>No Information</SASprocessnote> 138 138 </SASprocess> 139 139 <SASnote /> -
test/sansguiframe/test/utest_manipulations.py
r5777106 r75eeb425 15 15 16 16 def setUp(self): 17 self.data = Loader().load("cansas1d.xml") 17 data = Loader().load("cansas1d.xml") 18 self.data = data[0] 18 19 19 20 def test_clone1D(self): … … 29 30 30 31 def setUp(self): 31 self.data = Loader().load("cansas1d.xml") 32 data = Loader().load("cansas1d.xml") 33 self.data = data[0] 32 34 33 35 def test_clone_theory1D(self): -
test/sansinvariant/test/utest_data_handling.py
r5777106 r75eeb425 92 92 """ 93 93 def setUp(self): 94 self.data = Loader().load("latex_smeared_slit.xml") 94 data = Loader().load("latex_smeared_slit.xml") 95 self.data = data[0] 95 96 self.data.dxl = None 96 97 -
test/sansmodels/test/cansas1d_slit.xml
r5777106 r75eeb425 14 14 <I unit="1/cm">1000</I> 15 15 <Idev unit="1/cm">3</Idev> 16 <dQw unit="1/A">0.001</dQw> 16 17 <dQl unit="1/A">0.005</dQl> 17 <dQw unit="1/A">0.001</dQw> 18 <Shadowfactor><!-- Shadowfactor is optional --></Shadowfactor> 18 <Shadowfactor><!-- Shadowfactor is optional --></Shadowfactor> 19 19 </Idata> 20 20 <Idata> … … 22 22 <I unit="1/cm">1001</I> 23 23 <Idev unit="1/cm">4</Idev> 24 <dQw unit="1/A">0.001</dQw> 24 25 <dQl unit="1/A">0.005</dQl> 25 <dQw unit="1/A">0.001</dQw> 26 <Shadowfactor><!-- Shadowfactor is optional --></Shadowfactor> 26 <Shadowfactor><!-- Shadowfactor is optional --></Shadowfactor> 27 27 </Idata> 28 28 </SASdata> … … 49 49 50 50 </SASsample> 51 <SASinstrument name="TEST instrument">51 <SASinstrument> 52 52 <name>canSAS instrument</name> 53 53 <SASsource name="source name"> … … 85 85 4.150 86 86 </SDD> 87 <orientation> 87 <offset> 88 <x unit="mm">1</x> 89 <y unit="mm">2</y> 90 </offset> 91 <orientation> 88 92 <roll unit="degree">1.00</roll> 89 93 <pitch unit="degree">0.00</pitch> 90 94 <yaw unit="degree">0.00</yaw> 91 95 </orientation> 92 <offset>93 <x unit="mm">1</x>94 <y unit="mm">2</y>95 </offset>96 96 <beam_center> 97 97 <x unit="mm">322.64</x> -
test/sansmodels/test/utest_smearing.py
r5777106 r75eeb425 16 16 17 17 def setUp(self): 18 self.data = Loader().load("cansas1d_slit.xml") 18 data = Loader().load("cansas1d_slit.xml") 19 self.data = data[0] 19 20 20 21 x = 0.001*numpy.arange(1,11)
Note: See TracChangeset
for help on using the changeset viewer.