source: sasview/park_integration/test/small_test.py @ cf76ca74

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 cf76ca74 was 1e3169c, checked in by Gervaise Alina <gervyh@…>, 15 years ago

change fitdata1D to inheritates from dataloader.data1D

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"""
2    Unit tests for fitting module
3"""
4import unittest
5from sans.fit.AbstractFitEngine import Model
6import math
7from sans.fit.Fitting import Fit
8from DataLoader.loader import Loader
9
10class testFitModule(unittest.TestCase):
11    """ test fitting """
12    def test_park(self):
13        """ Simple cylinder model fit (scipy)  """
14       
15        out= Loader().load("cyl_400_20.txt")
16       
17        fitter = Fit('scipy')
18        # Receives the type of model for the fitting
19        from sans.models.CylinderModel import CylinderModel
20        model1  = CylinderModel()
21        model1.setParam('contrast', 1)
22        model = Model(model1)
23       
24        pars1 =['length','radius','scale']
25        fitter.set_data(out,1)
26        model.set( scale=1e-10 )
27        fitter.set_model(model,1,pars1)
28        fitter.select_problem_for_fit(Uid=1,value=1)
29        result1 = fitter.fit()
30       
31        self.assert_(result1)
32        self.assertTrue(len(result1.pvec)>0 or len(result1.pvec)==0 )
33        self.assertTrue(len(result1.stderr)> 0 or len(result1.stderr)==0)
34       
35        #print result1.pvec[0]-400.0, result1.pvec[0]
36        #print math.fabs(result1.pvec[0]-400.0)/3.0
37        self.assertTrue( math.fabs(result1.pvec[0]-400.0)/3.0 < result1.stderr[0] )
38        self.assertTrue( math.fabs(result1.pvec[1]-20.0)/3.0  < result1.stderr[1] )
39        self.assertTrue( math.fabs(result1.pvec[2]-9.0e-12)/3.0   < result1.stderr[2] )
40        self.assertTrue( result1.fitness < 1.0 )
41       
Note: See TracBrowser for help on using the repository browser.