ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change
on this file since 6df04e43 was
fd6b789,
checked in by Gervaise Alina <gervyh@…>, 15 years ago
|
refactor fit engine set_model can receive sans.model or park.model has a parameter;set_del has a new parameters constraints
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Rev | Line | |
---|
[8bbab51] | 1 | """ |
---|
| 2 | Unit tests for fitting module |
---|
| 3 | """ |
---|
| 4 | import unittest |
---|
| 5 | import math |
---|
| 6 | from sans.fit.Fitting import Fit |
---|
| 7 | from DataLoader.loader import Loader |
---|
| 8 | |
---|
| 9 | class testFitModule(unittest.TestCase): |
---|
| 10 | """ test fitting """ |
---|
| 11 | def test_park(self): |
---|
[1e3169c] | 12 | """ Simple cylinder model fit (scipy) """ |
---|
[8bbab51] | 13 | |
---|
[1e3169c] | 14 | out= Loader().load("cyl_400_20.txt") |
---|
| 15 | |
---|
[1ea3488] | 16 | fitter = Fit('scipy') |
---|
[8bbab51] | 17 | # Receives the type of model for the fitting |
---|
| 18 | from sans.models.CylinderModel import CylinderModel |
---|
[fd6b789] | 19 | model = CylinderModel() |
---|
| 20 | model.setParam('contrast', 1) |
---|
| 21 | |
---|
[8bbab51] | 22 | pars1 =['length','radius','scale'] |
---|
[1e3169c] | 23 | fitter.set_data(out,1) |
---|
[fd6b789] | 24 | model.setParam('scale', 1e-10) |
---|
| 25 | fitter.set_model(model,1,pars1, constraints=()) |
---|
[8bbab51] | 26 | fitter.select_problem_for_fit(Uid=1,value=1) |
---|
| 27 | result1 = fitter.fit() |
---|
| 28 | |
---|
| 29 | self.assert_(result1) |
---|
| 30 | self.assertTrue(len(result1.pvec)>0 or len(result1.pvec)==0 ) |
---|
| 31 | self.assertTrue(len(result1.stderr)> 0 or len(result1.stderr)==0) |
---|
| 32 | |
---|
| 33 | #print result1.pvec[0]-400.0, result1.pvec[0] |
---|
| 34 | #print math.fabs(result1.pvec[0]-400.0)/3.0 |
---|
| 35 | self.assertTrue( math.fabs(result1.pvec[0]-400.0)/3.0 < result1.stderr[0] ) |
---|
| 36 | self.assertTrue( math.fabs(result1.pvec[1]-20.0)/3.0 < result1.stderr[1] ) |
---|
| 37 | self.assertTrue( math.fabs(result1.pvec[2]-9.0e-12)/3.0 < result1.stderr[2] ) |
---|
| 38 | self.assertTrue( result1.fitness < 1.0 ) |
---|
| 39 | |
---|
Note: See
TracBrowser
for help on using the repository browser.