Changeset 93c2ef2 in sasview for park_integration/test
- Timestamp:
- May 21, 2008 11:10:45 AM (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:
- acb8788
- Parents:
- 4a0536a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
park_integration/test/testfitting.py
r4a0536a r93c2ef2 2 2 Unit tests for fitting module 3 3 """ 4 import unittest ,fittings4 import unittest 5 5 from sans.guitools.plottables import Theory1D 6 6 from sans.guitools.plottables import Data1D 7 from FittingModule import Parameter 8 import math 7 9 class testFitModule(unittest.TestCase): 8 10 """ test fitting """ … … 55 57 load= Load() 56 58 load.set_filename("testdata_line.txt") 57 self.assertEqual(load.get_filename(),"testdata_line.txt")58 59 load.set_values() 59 60 x,y,dx,dy = load.get_values() 60 61 61 data1 = Data1D(x=[], y=[],dx=None, dy=None) 62 62 load.load_data(data1) 63 63 64 # Receives the type of model for the fitting 64 65 from sans.guitools.LineModel import LineModel 65 self.model = LineModel()66 66 model = LineModel() 67 67 68 from FittingModule import Fitting 68 fitting= Fitting(data1,None) 69 fitting.set_model(self.model) 70 self.assertEqual(fitting.fit_engine(),True) 71 fitting.set_data(x,y,dx,dy) 72 chisqr, out, cov= fitting.fit() 73 self.assertAlmostEqual(out[1],2.5) 74 self.assertAlmostEquals(out[0],4.0) 75 self.assertAlmostEquals(out[1]+cov[1][1],2.5) 76 self.assertAlmostEquals(out[0]+cov[0][0],4.0) 69 Fit= Fitting() 70 Fit.set_data(data1) 71 Fit.set_model(model) 77 72 73 default_A = model.getParam('A') 74 default_B = model.getParam('B') 75 cstA = Parameter(model, 'A', default_A) 76 cstB = Parameter(model, 'B', default_B) 77 chisqr, out, cov=Fit.fit([cstA,cstB],None,None) 78 print"fit only one data",chisqr, out, cov 79 80 self.assertEqual(Fit.fit_engine(),True) 81 82 self.assert_(math.fabs(out[1]-2.5)/math.sqrt(cov[1][1]) < 2) 83 print "chisqr",chisqr/len(data1.x) 84 self.assert_(chisqr/len(data1.x) < 2) 85 # self.assertAlmostEqual(out[1],2.5) 86 #self.assertAlmostEquals(out[0],4.0) 87 #self.assertAlmostEquals(out[1]+cov[1][1],2.5) 88 #self.assertAlmostEquals(out[0]+cov[0][0],4.0) 89
Note: See TracChangeset
for help on using the changeset viewer.