- Timestamp:
- May 15, 2014 11:23:22 AM (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:
- 4e9f227
- Parents:
- 76f132a
- Location:
- test/park_integration/test
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
test/park_integration/test/batch_fit.py
r4de1fed re3efa6b3 1 2 3 1 import copy 4 2 import time … … 13 11 14 12 15 16 17 13 def classMapper(classInstance, classFunc, *args): 18 14 """ … … 26 22 27 23 28 29 class BatchScipyFit: 24 class BatchFit: 30 25 """ 31 26 test fit module … … 67 62 model.setParam('cyl_phi.npts', 3) 68 63 model.setParam('cyl_theta.nsigmas', 10) 69 """ for 2 data cyl_theta = 60.0 [deg] cyl_phi= 60.0 [deg]"""64 # for 2 data cyl_theta = 60.0 [deg] cyl_phi= 60.0 [deg] 70 65 fitter.set_model(model, i, self.param_to_fit, 71 66 self.list_of_constraints) … … 82 77 self.list_of_mapper.append(classMapper) 83 78 84 def reset_value(self ):79 def reset_value(self, engine='scipy'): 85 80 """ 86 81 Initialize inputs for the map function … … 91 86 self.list_of_constraints = [] 92 87 self.list_of_mapper = [] 93 engine ="scipy" 94 88 95 89 path = "testdata_line3.txt" 96 90 self._reset_helper(path=path, engine=engine, npts=NPTS) … … 111 105 112 106 113 def test_map_fit(self ):107 def test_map_fit(self, n=0): 114 108 """ 115 """ 116 results = map(classMapper,self.list_of_fitter, self.list_of_function) 117 print len(results) 118 for result in results: 119 print result.fitness, result.stderr, result.pvec 109 """ 110 if n > 0: 111 self._test_process_map_fit(n=n) 112 else: 113 results = map(classMapper,self.list_of_fitter, self.list_of_function) 114 print len(results) 115 for result in results: 116 print result.fitness, result.stderr, result.pvec 120 117 121 118 def test_process_map_fit(self, n=1): … … 142 139 """ 143 140 def setUp(self): 144 self.test = Batch ScipyFit(qmin=None, qmax=None)141 self.test = BatchFit(qmin=None, qmax=None) 145 142 146 143 147 def __test_fit1(self):144 def test_fit1(self): 148 145 """test fit with python built in map function---- full range of each data""" 149 146 self.test.test_map_fit() 150 147 151 def __test_fit2(self):148 def test_fit2(self): 152 149 """test fit with python built in map function---- common range for all data""" 153 150 self.test.set_range(qmin=0.013, qmax=0.05) 154 151 self.test.reset_value() 155 152 self.test.test_map_fit() 153 raise Exception("fail") 156 154 157 155 def test_fit3(self): … … 159 157 self.test.set_range(qmin=None, qmax=None) 160 158 self.test.reset_value() 161 self.test.test_ process_map_fit(n=2)159 self.test.test_map_fit(n=1) 162 160 163 161 def test_fit4(self): … … 165 163 self.test.set_range(qmin=-1, qmax=10) 166 164 self.test.reset_value() 167 self.test.test_ process_map_fit(n=1)165 self.test.test_map_fit(n=3) 168 166 169 167 -
test/park_integration/test/utest_fit_cylinder.py
rfb7180c re3efa6b3 95 95 self.model2.set(background=0.0) 96 96 97 def _fit(self, name="park"):98 """ return fit result """99 fitter = Fit(name)100 fitter.set_data(self.data1,1)101 fitter.set_model(self.model1, 1, ['length','radius','scale'])102 97 103 fitter.set_data(self.data2,2)104 fitter.set_model(self.model2, 2, ['radius','scale'])105 fitter.select_problem_for_fit(id=1,value=1)106 fitter.select_problem_for_fit(id=2,value=1)107 return fitter.fit()108 109 110 98 def test_park2(self): 111 99 """ Simultaneous cylinder model fit (park) """ 112 result1, result2 = self._fit('park') 100 self._run_fit(Fit('park')) 101 102 def _run_fit(self, fitter): 103 result1, result2 = self._fit(fitter) 113 104 self.assert_(result1) 114 105 self.assertTrue(len(result1.pvec)>0) … … 130 121 self.assertTrue( math.fabs(v-1.0)/3.0 < dv ) 131 122 123 def _fit(self, fitter): 124 """ return fit result """ 125 fitter.set_data(self.data1,1) 126 fitter.set_model(self.model1, 1, ['length','radius','scale']) 127 128 fitter.set_data(self.data2,2) 129 fitter.set_model(self.model2, 2, ['radius','scale']) 130 fitter.select_problem_for_fit(id=1,value=1) 131 fitter.select_problem_for_fit(id=2,value=1) 132 return fitter.fit() 133 132 134 133 135 if __name__ == '__main__': -
test/park_integration/test/utest_fit_line.py
r76f132a re3efa6b3 89 89 self.fit_bumps('newton') 90 90 91 def test_bumps_lm(self): 92 self.fit_bumps('lm') 93 91 94 def test_scipy(self): 92 95 #print "fitting scipy" -
test/park_integration/test/utest_fit_smeared.py
r76f132a re3efa6b3 5 5 import unittest 6 6 import math 7 7 8 import numpy 8 9 from sans.fit.AbstractFitEngine import Model … … 62 63 Cylinder fit with dispersion 63 64 """ 64 alg = ' amoeba'65 alg = 'lm' 65 66 from bumps import fitters 66 67 fitters.FIT_DEFAULT = alg … … 103 104 fitter.set_model(model,1,pars1) 104 105 fitter.select_problem_for_fit(id=1,value=1) 105 result1, = fitter.fit() 106 #import time; T0 = time.time() 107 result1, = fitter.fit() 108 #print "time",time.time()-T0,fitter._engine.__class__.__name__ 106 109 107 110 self.assert_(result1) … … 109 112 self.assertTrue(len(result1.stderr)>0) 110 113 114 #print [z for z in zip(result1.param_list,result1.pvec,result1.stderr)] 111 115 self.assertTrue( math.fabs(result1.pvec[0]-399.8)/3.0 < result1.stderr[0] ) 112 116 self.assertTrue( math.fabs(result1.pvec[1]-17.5)/3.0 < result1.stderr[1] )
Note: See TracChangeset
for help on using the changeset viewer.