- Timestamp:
- May 15, 2014 7:07:43 PM (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:
- 786685e
- Parents:
- e3efa6b3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
test/park_integration/test/utest_fit_cylinder.py
re3efa6b3 r4e9f227 10 10 from sans.dataloader.loader import Loader 11 11 12 #@unittest.skip("") 12 13 class TestSingleFit(unittest.TestCase): 13 14 """ test single fitting """ … … 33 34 fitter.set_model(self.model,1,self.pars1) 34 35 fitter.select_problem_for_fit(id=1,value=1) 35 return fitter.fit() 36 36 result1, = fitter.fit() 37 37 38 def test_scipy(self):39 """ Simple cylinder model fit (scipy) """40 41 result1, = self._fit("scipy")42 43 38 self.assert_(result1) 44 39 self.assertTrue(len(result1.pvec)>0 or len(result1.pvec)==0 ) 45 40 self.assertTrue(len(result1.stderr)> 0 or len(result1.stderr)==0) 46 41 47 42 self.assertTrue( math.fabs(result1.pvec[0]-400.0)/3.0 < result1.stderr[0] ) 48 43 self.assertTrue( math.fabs(result1.pvec[1]-20.0)/3.0 < result1.stderr[1] ) 49 44 self.assertTrue( math.fabs(result1.pvec[2]-1.0)/3.0 < result1.stderr[2] ) 50 45 self.assertTrue( result1.fitness < 1.0 ) 51 52 46 47 48 def test_scipy(self): 49 """ Simple cylinder model fit (scipy) """ 50 self._fit("scipy") 51 52 53 53 def test_park(self): 54 54 """ Simple cylinder model fit (park) """ 55 #raise NotImplementedError() 56 result1, = self._fit("park") 57 58 self.assert_(result1) 59 self.assertTrue(len(result1.pvec)>0 or len(result1.pvec)==0 ) 60 self.assertTrue(len(result1.stderr)> 0 or len(result1.stderr)==0) 61 62 self.assertTrue( math.fabs(result1.pvec[0]-400.0)/3.0 < result1.stderr[0] ) 63 self.assertTrue( math.fabs(result1.pvec[1]-20.0)/3.0 < result1.stderr[1] ) 64 self.assertTrue( math.fabs(result1.pvec[2]-1.0)/3.0 < result1.stderr[2] ) 65 self.assertTrue( result1.fitness < 1.0 ) 66 67 55 self._fit("park") 56 57 def test_bumps(self): 58 """ Simple cylinder model fit (park) """ 59 self._fit("bumps") 60 61 68 62 69 63 class TestSimultaneousFit(unittest.TestCase): … … 82 76 self.model1.set(scale= 1.0) 83 77 self.model1.set(radius=18) 84 self.model1.set(length= 396)78 self.model1.set(length=200) 85 79 self.model1.set(sldCyl=3e-006, sldSolv=0.0) 86 80 self.model1.set(background=0.0) 87 81 88 82 cyl2 = CylinderModel() 89 83 cyl2.name = "C2" … … 91 85 self.model2.set(scale= 1.0) 92 86 self.model2.set(radius=37) 93 self.model2.set(length= 'C1.length')87 self.model2.set(length=300) 94 88 self.model2.set(sldCyl=3e-006, sldSolv=0.0) 95 89 self.model2.set(background=0.0) 96 97 90 98 def test_park2(self): 91 92 def test_constrained_bumps(self): 93 """ Simultaneous cylinder model fit (park) """ 94 self._run_fit(Fit('bumps')) 95 96 #@unittest.skip("") 97 def test_constrained_park(self): 99 98 """ Simultaneous cylinder model fit (park) """ 100 99 self._run_fit(Fit('park')) … … 107 106 108 107 for n, v, dv in zip(result1.param_list, result1.pvec, result1.stderr): 109 print " M1.%s = %s +/- %s"%(n,v,dv)108 print "%s M1.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 110 109 if n == "length": 111 110 self.assertTrue( math.fabs(v-400.0)/3.0 < dv ) … … 115 114 self.assertTrue( math.fabs(v-1.0)/3.0 < dv ) 116 115 for n, v, dv in zip(result2.param_list, result2.pvec, result2.stderr): 117 print " M2.%s = %s +/- %s"%(n,v,dv)116 print "%s M2.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 118 117 if n=='radius': 119 118 self.assertTrue( math.fabs(v-40.0)/3.0 < dv ) … … 127 126 128 127 fitter.set_data(self.data2,2) 129 fitter.set_model(self.model2, 2, ['radius','scale']) 128 fitter.set_model(self.model2, 2, ['radius','scale'], 129 constraints=[("length","C1.length")]) 130 130 fitter.select_problem_for_fit(id=1,value=1) 131 131 fitter.select_problem_for_fit(id=2,value=1)
Note: See TracChangeset
for help on using the changeset viewer.