source: sasview/park_integration/test/testnewscipy.py @ 4fc6dbf

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 4fc6dbf was 388309d, checked in by Gervaise Alina <gervyh@…>, 16 years ago

park_integration working better for large model

  • Property mode set to 100644
File size: 2.4 KB
Line 
1"""
2    Unit tests for fitting module
3"""
4import unittest
5from sans.guitools.plottables import Theory1D
6from sans.guitools.plottables import Data1D
7from sans.fit.AbstractFitEngine import Data, Model
8import math
9class testFitModule(unittest.TestCase):
10    """ test fitting """
11   
12    def testfit_1Data_1Model(self):
13        """ test fitting for one data and one model park vs scipy"""
14        #load data
15        from sans.fit.Loader import Load
16        load= Load()
17        load.set_filename("testdata_line.txt")
18        load.set_values()
19        data11 = Data1D(x=[], y=[],dx=None, dy=None)
20        load.load_data(data11)
21       
22        #Importing the Fit module
23        from sans.fit.Fitting import Fit
24        fitter= Fit('park')
25       
26        # Receives the type of model for the fitting
27        from sans.guitools.LineModel import LineModel
28        model1  = LineModel()
29        data1=Data(sans_data=data11)
30        model =Model(model1)
31        #Do the fit SCIPY
32       
33        fitter.set_data(data1,1)
34        fitter.set_model(model,"M1",1,['A','B'])
35   
36        result=fitter.fit()
37        print "park",result.pvec,
38       
39        self.assert_(result)
40     
41    def test_cylinder_scipy(self):
42        """ test fitting large model with scipy"""
43        #load data
44        from sans.fit.Loader import Load
45        load= Load()
46        load.set_filename("cyl_testdata.txt")
47        load.set_values()
48        data11 = Data1D(x=[], y=[],dx=None, dy=None)
49        load.load_data(data11)
50        data1=Data(sans_data=data11)
51       
52       
53        #Importing the Fit module
54        from sans.fit.Fitting import Fit
55        fitter= Fit('park')
56       
57        # Receives the type of model for the fitting
58        from sans.models.CylinderModel import CylinderModel
59        model1  = CylinderModel()
60        model =Model(model1)
61       
62        #Do the fit SCIPY
63        fitter.set_data(data1,1)
64        import math
65        pars1=['background','contrast', 'length']
66        #pars1=['background','contrast',\
67        #        'cyl_phi','cyl_theta','length','radius','scale']
68        pars1.sort()
69        fitter.set_model(model,"M1",1,pars1)
70        fitter.set_data(data1,1)
71     
72        result=fitter.fit()
73        print "park",result.fitness,result.cov, result.pvec
74        self.assert_(result.fitness)
75       
76   
77     
Note: See TracBrowser for help on using the repository browser.