Changeset e89bb46 in sasview
- Timestamp:
- Jun 20, 2012 11:25:19 AM (13 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:
- c4f79f0
- Parents:
- 20efe7b
- Files:
-
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/test/utest_manipulations.py
r4a47244 re89bb46 257 257 self.assertEqual(result.err_data[i], 6.0*0.5/4.0) 258 258 259 class extra_manip_2D(unittest.TestCase): 260 261 def setUp(self): 262 # Create two data sets to play with 263 x_0 = 2.0*numpy.ones(25) 264 dx_0 = 0.5*numpy.ones(25) 265 qx_0 = numpy.arange(25) 266 qy_0 = numpy.arange(25) 267 mask_0 = numpy.zeros(25) 268 dqx_0 = numpy.arange(25)/100 269 dqy_0 = numpy.arange(25)/100 270 q_0 = numpy.sqrt(qx_0 * qx_0 + qy_0 * qy_0) 271 self.data = Data2D(image=x_0, err_image=dx_0, qx_data=qx_0, 272 qy_data=qy_0, q_data=q_0, mask=mask_0, 273 dqx_data=dqx_0, dqy_data=dqy_0) 274 275 y = numpy.ones(25) 276 dy = numpy.ones(25) 277 qx = numpy.arange(25) 278 qy = numpy.arange(25) 279 mask = numpy.zeros(25) 280 q = numpy.sqrt(qx * qx + qy * qy) 281 self.data2 = Data2D(image=y, err_image=dy, qx_data=qx, qy_data=qy, 282 q_data=q, mask=mask) 283 284 285 def test_load(self): 286 """ 287 Test whether the test file was loaded properly 288 """ 289 # There should be 5 entries in the file 290 self.assertEqual(numpy.size(self.data.data), 25) 291 292 for i in range(25): 293 # All y-error values should be 0.5 294 self.assertEqual(self.data.err_data[i], 0.5) 295 296 # All y values should be 2.0 297 self.assertEqual(self.data.data[i], 2.0) 298 299 def test_add(self): 300 result = self.data2+self.data 301 for i in range(25): 302 self.assertEqual(result.data[i], 3.0) 303 self.assertEqual(result.err_data[i], math.sqrt(0.5**2+1.0)) 304 305 def test_sub(self): 306 result = self.data2-self.data 307 for i in range(25): 308 self.assertEqual(result.data[i], -1.0) 309 self.assertEqual(result.err_data[i], math.sqrt(0.5**2+1.0)) 310 311 def test_mul(self): 312 result = self.data2*self.data 313 for i in range(25): 314 self.assertEqual(result.data[i], 2.0) 315 self.assertEqual(result.err_data[i], math.sqrt((0.5*1.0)**2+(1.0*2.0)**2)) 316 317 def test_div(self): 318 result = self.data2/self.data 319 for i in range(25): 320 self.assertEqual(result.data[i], 0.5) 321 self.assertEqual(result.err_data[i], math.sqrt((1.0/2.0)**2+(0.5*1.0/4.0)**2)) 322 323 def test_radd(self): 324 result = self.data+3.0 325 for i in range(25): 326 self.assertEqual(result.data[i], 5.0) 327 self.assertEqual(result.err_data[i], 0.5) 328 329 result = 3.0+self.data 330 for i in range(25): 331 self.assertEqual(result.data[i], 5.0) 332 self.assertEqual(result.err_data[i], 0.5) 333 334 def test_rsub(self): 335 result = self.data-3.0 336 for i in range(25): 337 self.assertEqual(result.data[i], -1.0) 338 self.assertEqual(result.err_data[i], 0.5) 339 340 result = 3.0-self.data 341 for i in range(25): 342 self.assertEqual(result.data[i], 1.0) 343 self.assertEqual(result.err_data[i], 0.5) 344 345 def test_rmul(self): 346 result = self.data*3.0 347 for i in range(25): 348 self.assertEqual(result.data[i], 6.0) 349 self.assertEqual(result.err_data[i], 1.5) 350 351 result = 3.0*self.data 352 for i in range(25): 353 self.assertEqual(result.data[i], 6.0) 354 self.assertEqual(result.err_data[i], 1.5) 355 356 def test_rdiv(self): 357 result = self.data/4.0 358 for i in range(25): 359 self.assertEqual(result.data[i], 0.5) 360 self.assertEqual(result.err_data[i], 0.125) 361 362 result = 6.0/self.data 363 for i in range(25): 364 self.assertEqual(result.data[i], 3.0) 365 self.assertEqual(result.err_data[i], 6.0*0.5/4.0) 259 366 260 367 if __name__ == '__main__': -
test/utest_sansview.py
rd7b49576 re89bb46 9 9 print "Try easy_install unittest-xml-reporting" 10 10 11 # Check whether we have matplotlib installed 12 HAS_MPL = True 13 try: 14 import matplotlib 15 except: 16 HAS_MPL = False 17 11 18 SKIPPED_DIRS = ["sansrealspace", "calculatorview"] 19 if not HAS_MPL: 20 SKIPPED_DIRS.append("sansguiframe") 21 12 22 SANSVIEW_DIR = os.pardir 13 23 COMMAND_SEP = ';'
Note: See TracChangeset
for help on using the changeset viewer.