Changeset c75a8ed in sasview for Invariant/test
- Timestamp:
- Mar 6, 2010 10:18:04 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:
- 21d99c2
- Parents:
- 2661d8b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Invariant/test/utest_data_handling.py
rbdd162f rc75a8ed 281 281 self.assertTrue(math.fabs(qs_extr-qstar)<dqs_extr) 282 282 283 def _check_values(to_check, reference, tolerance=0.05): 284 self.assertTrue( math.fabs(to_check-reference)/reference < tolerance, msg="Tested value = "+str(to_check) ) 285 286 # The following values should be replaced by values pulled from IGOR 287 # Volume Fraction: 288 v, dv = inv.get_volume_fraction_with_error(1, None) 289 _check_values(v, 1.88737914186e-15) 290 291 v_l, dv_l = inv.get_volume_fraction_with_error(1, 'low') 292 _check_values(v_l, 1.94289029309e-15) 293 294 v_h, dv_h = inv.get_volume_fraction_with_error(1, 'high') 295 _check_values(v_h, 6.99440505514e-15) 296 297 v_b, dv_b = inv.get_volume_fraction_with_error(1, 'both') 298 _check_values(v_b, 6.99440505514e-15) 299 300 # Specific Surface: 301 s, ds = inv.get_surface_with_error(1, 1, None) 302 _check_values(s, 3.1603095786e-09) 303 304 s_l, ds_l = inv.get_surface_with_error(1, 1, 'low') 305 _check_values(s_l, 3.1603095786e-09) 306 307 s_h, ds_h = inv.get_surface_with_error(1, 1, 'high') 308 _check_values(s_h, 3.1603095786e-09) 309 310 s_b, ds_b = inv.get_surface_with_error(1, 1, 'both') 311 _check_values(s_b, 3.1603095786e-09) 312 313 283 314 def test_bad_parameter_name(self): 284 315 """ … … 461 492 462 493 qstar = inv.get_qstar(extrapolation='low') 463 reel_y = self.data.y464 494 test_y = inv._low_extrapolation_function.evaluate_model(x=self.data.x) 465 495 for i in range(len(self.data.x)): 466 value = math.fabs(test_y[i]- reel_y[i])/reel_y[i]496 value = math.fabs(test_y[i]-self.data.y[i])/self.data.y[i] 467 497 self.assert_(value < 0.001) 468 498 … … 470 500 """ 471 501 for a smear data, test that the fitting go through 472 re el data for atleast the 2 first points502 real data for atleast the 2 first points 473 503 """ 474 504 … … 483 513 y = numpy.asarray([self.scale * math.exp( -(q*self.rg)**2 / 3.0 ) for q in x]) 484 514 dy = y*.1 485 dxl = 0.117 * numpy.ones(len(x))486 515 self.data = Data1D(x=x, y=y, dy=dy) 487 self.data.dxl = dxl488 516 self.npts = len(x)-10 489 517 … … 512 540 513 541 qstar = inv.get_qstar(extrapolation='low') 514 reel_y = self.data.y 515 #Compution the y 's coming out of the invariant when computing extrapolated 516 #low data . expect the fit engine to have been already called and the guinier 517 # to have the radius and the scale fitted 542 518 543 test_y = inv._low_extrapolation_function.evaluate_model(x=self.data.x[:inv._low_extrapolation_npts]) 519 self.assert_(len(test_y) )== len(reel_y[:inv._low_extrapolation_npts])544 self.assert_(len(test_y) == len(self.data.y[:inv._low_extrapolation_npts])) 520 545 521 546 for i in range(inv._low_extrapolation_npts): 522 value = math.fabs(test_y[i]- reel_y[i])/reel_y[i]547 value = math.fabs(test_y[i]-self.data.y[i])/self.data.y[i] 523 548 self.assert_(value < 0.001) 524 549 … … 547 572 548 573 qstar = inv.get_qstar(extrapolation='low') 549 reel_y = self.data.y550 574 #Compution the y 's coming out of the invariant when computing extrapolated 551 575 #low data . expect the fit engine to have been already called and the guinier 552 576 # to have the radius and the scale fitted 553 data_out_range, data_in_range= inv.get_extra_data_low() 577 data_in_range = inv.get_extra_data_low(q_start=self.data.x[0], 578 npts = inv._low_extrapolation_npts) 554 579 test_y = data_in_range.y 555 self.assert_(len(test_y) )== len(reel_y[:inv._low_extrapolation_npts])580 self.assert_(len(test_y) == len(self.data.y[:inv._low_extrapolation_npts])) 556 581 for i in range(inv._low_extrapolation_npts): 557 value = math.fabs(test_y[i]- reel_y[i])/reel_y[i]582 value = math.fabs(test_y[i]-self.data.y[i])/self.data.y[i] 558 583 self.assert_(value < 0.001) 559 560 data_out_range, data_in_range= inv.get_extra_data_low(npts_in= 2, nsteps=10, 561 q_start= 1e-4) 562 test_y = data_in_range.y 563 self.assert_(len(test_y))== len(reel_y[:2]) 564 for i in range(2): 565 value = math.fabs(test_y[i]-reel_y[i])/reel_y[i] 566 self.assert_(value < 0.001) 567 #test the data out of range 568 test_out_y = data_out_range.y 569 #self.assertEqual(len(test_out_y), 10) 584 570 585 571 586 class TestDataExtraHighSlitPowerLaw(unittest.TestCase): 572 587 """ 573 588 for a smear data, test that the fitting go through 574 re el data for atleast the 2 first points589 real data for atleast the 2 first points 575 590 """ 576 591 … … 586 601 dy = y*.1 587 602 self.data = Data1D(x=x, y=y, dy=dy) 588 dxl = 0.117 * numpy.ones(len(x))589 self.data.dxl = dxl590 603 self.npts = 20 591 604 … … 616 629 617 630 qstar = inv.get_qstar(extrapolation='high') 618 reel_y = self.data.y619 #Compution the y 's coming out of the invariant when computing extrapolated620 #low data . expect the fit engine to have been already called and the power law621 # to have the radius and the scale fitted622 623 631 624 632 test_y = inv._high_extrapolation_function.evaluate_model(x=self.data.x[start: ]) 625 self.assert_(len(test_y) )== len(reel_y[start:])633 self.assert_(len(test_y) == len(self.data.y[start:])) 626 634 627 635 for i in range(len(self.data.x[start:])): 628 value = math.fabs(test_y[i]- reel_y[start+i])/reel_y[start+i]636 value = math.fabs(test_y[i]-self.data.y[start+i])/self.data.y[start+i] 629 637 self.assert_(value < 0.001) 630 638 … … 654 662 655 663 qstar = inv.get_qstar(extrapolation='high') 656 reel_y = self.data.y657 #Compution the y 's coming out of the invariant when computing extrapolated658 #low data . expect the fit engine to have been already called and the power law659 # to have the radius and the scale fitted660 664 661 data_out_range, data_in_range= inv.get_extra_data_high() 665 data_in_range= inv.get_extra_data_high(q_end = max(self.data.x), 666 npts = inv._high_extrapolation_npts) 662 667 test_y = data_in_range.y 663 self.assert_(len(test_y) )== len(reel_y[start:])664 temp = reel_y[start:]668 self.assert_(len(test_y) == len(self.data.y[start:])) 669 temp = self.data.y[start:] 665 670 666 671 for i in range(len(self.data.x[start:])): 667 672 value = math.fabs(test_y[i]- temp[i])/temp[i] 668 self.assert_(value < 0.001) 669 670 data_out_range, data_in_range= inv.get_extra_data_high(npts_in=5, nsteps=10, 671 q_end= 2) 672 test_y = data_in_range.y 673 self.assert_(len(test_y)==5) 674 temp = reel_y[start:start+5] 675 676 for i in range(len(self.data.x[start:start+5])): 677 678 value = math.fabs(test_y[i]- temp[i])/temp[i] 679 self.assert_(value < 0.06) 680 #test the data out of range 681 test_out_y = data_out_range.y 682 self.assertEqual(len(test_out_y), 10) 673 self.assert_(value < 0.001) 683 674
Note: See TracChangeset
for help on using the changeset viewer.