Changeset 3701620 in sasview
- Timestamp:
- Jun 19, 2008 3:52:46 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:
- fbc51ef
- Parents:
- 9b85e93
- Location:
- park_integration
- Files:
-
- 6 added
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
park_integration/test/testfitting.py
r495809d r3701620 63 63 64 64 #Importing the Fit module 65 from FittingModule import Fitting 66 Fit= Fitting() 65 from Fitting import Fit 66 fitter= Fit() 67 fitter.fit_engine('scipy') 68 engine = fitter.returnEngine() 67 69 # Receives the type of model for the fitting 68 70 from sans.guitools.LineModel import LineModel 69 71 model = LineModel() 70 72 73 #Do the fit SCIPY 74 engine.set_data(data1,1) 75 engine.set_model(model,1) 76 77 chisqr1, out1, cov1=engine.fit({'A':2,'B':1},None,None) 78 """ testing SCIPy results""" 79 self.assert_(math.fabs(out1[1]-2.5)/math.sqrt(cov1[1][1]) < 2) 80 self.assert_(math.fabs(out1[0]-4.0)/math.sqrt(cov1[0][0]) < 2) 81 self.assert_(chisqr1/len(data1.x) < 2) 82 # PARK 83 fitter= Fit() 84 fitter.fit_engine('park') 85 engine = fitter.returnEngine() 86 71 87 #Do the fit 72 Fit.set_data(data1,1) 73 Fit.set_model(model,1) 74 self.assertEqual(Fit.fit_engine("scipy"),True) 75 chisqr, out, cov=Fit.fit({'A':2,'B':1},None,None) 76 #print"fit only one data",chisqr, out, cov 77 #Testing results 78 79 self.assert_(math.fabs(out[1]-2.5)/math.sqrt(cov[1][1]) < 2) 80 self.assert_(math.fabs(out[0]-4.0)/math.sqrt(cov[0][0]) < 2) 81 self.assert_(chisqr/len(data1.x) < 2) 82 83 #print "chisqr",chisqr/len(data1.x) 84 #print "Error on A",math.fabs(out[1]-2.5)/math.sqrt(cov[1][1]) 85 #print "Error on B",math.fabs(out[0]-4.0)/math.sqrt(cov[0][0]) 86 88 engine.set_data(data1,1) 89 engine.set_model(model,1) 90 91 engine.fit({'A':2,'B':1},None,None) 92 """ 93 94 self.assert_(math.fabs(out2[1]-2.5)/math.sqrt(cov2[1][1]) < 2) 95 self.assert_(math.fabs(out2[0]-4.0)/math.sqrt(cov2[0][0]) < 2) 96 self.assert_(chisqr2/len(data1.x) < 2) 97 98 self.assertEqual(out1[1], out2[1]) 99 self.assertEquals(out1[0], out2[0]) 100 self.assertEquals(cov1[0][0], cov2[0][0]) 101 self.assertEquals(cov1[1][1], cov2[1][1]) 102 self.assertEquals(chisqr1, chisqr2) 103 """ 87 104 def testfit_2Data_1Model(self): 88 """ test fitting for two set of data dataand one model"""105 """ test fitting for two set of data and one model""" 89 106 from Loader import Load 90 107 load= Load() … … 102 119 103 120 #Importing the Fit module 104 from Fitting Module import Fitting105 Fit= Fitting()121 from Fitting import Fit 122 fitter= Fit() 106 123 # Receives the type of model for the fitting 107 124 from sans.guitools.LineModel import LineModel 108 125 model = LineModel() 126 #set engine for scipy 127 fitter.fit_engine('scipy') 128 engine = fitter.returnEngine() 129 #Do the fit 130 engine.set_model(model,1) 131 engine.set_data(data1,1) 132 engine.set_data(data2,1) 133 109 134 135 chisqr1, out1, cov1= engine.fit({'A':2,'B':1},None,None) 136 137 """ Testing results for SCIPY""" 138 self.assert_(math.fabs(out1[1]-2.5)/math.sqrt(cov1[1][1]) < 2) 139 self.assert_(math.fabs(out1[0]-4.0)/math.sqrt(cov1[0][0]) < 2) 140 self.assert_(chisqr1/len(data1.x+data2.x) < 2) 141 #self.assert_(chisqr1/len(data2.x) < 2) 142 143 #set engine for park 144 fitter= Fit() 145 fitter.fit_engine('park') 146 engine = fitter.returnEngine() 110 147 #Do the fit 111 Fit.set_data(data1,1) 112 Fit.set_model(model,1) 113 114 Fit.set_data(data2,2) 115 Fit.set_model(model,2) 116 self.assertEqual(Fit.fit_engine("scipy"),True) 117 self.assertEqual(Fit.fit_engine("scipys"),False) 118 chisqr, out, cov=Fit.fit({'A':2,'B':1},None,None) 119 #print"fit only one data",chisqr, out, cov 120 121 #Testing results 122 123 self.assert_(math.fabs(out[1]-2.5)/math.sqrt(cov[1][1]) < 2) 124 self.assert_(math.fabs(out[0]-4.0)/math.sqrt(cov[0][0]) < 2) 125 self.assert_(chisqr/len(data1.x) < 2) 126 127 148 engine.set_data(data1,1) 149 engine.set_model(model,1) 150 engine.set_data(data2,1) 151 engine.fit({'A':2,'B':1},None,None) 152 """ 153 chisqr2, out2, cov2= engine.fit({'A':2,'B':1},None,None) 154 155 156 self.assert_(math.fabs(out2[1]-2.5)/math.sqrt(cov2[1][1]) < 2) 157 self.assert_(math.fabs(out2[0]-4.0)/math.sqrt(cov2[0][0]) < 2) 158 self.assert_(chisqr2/len(data1.x) < 2) 159 self.assert_(chisqr2/len(data2.x) < 2) 160 161 self.assertEqual(out1[0],out2[0]) 162 self.assertEqual(out1[1],out2[1]) 163 self.assertEqual(chisqr1,chisqr2) 164 self.assertEqual(cov1[0][0],cov2[0][0]) 165 self.assertEqual(cov1[1][1],cov2[1][1]) 166 """
Note: See TracChangeset
for help on using the changeset viewer.