source: sasview/park_integration/test/testnewscipys.py @ dabb633

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 dabb633 was d831626, checked in by Gervaise Alina <gervyh@…>, 16 years ago

park integration test_large_model is not working for park

  • Property mode set to 100644
File size: 3.5 KB
Line 
1"""
2    test Data, Model , fucntor classes of AbstractFittingModule
3"""
4import unittest
5from sans.guitools.plottables import Theory1D
6from sans.guitools.plottables import Data1D
7from sans.fit.AbstractFitEngine import Data, Model
8from sans.fit.AbstractFitEngine import sansAssembly
9import math
10class testFitModule(unittest.TestCase):
11    """ test fitting """
12   
13    def test_Data(self):
14        """ test Data"""
15        #load data
16        from sans.fit.Loader import Load
17        load= Load()
18        load.set_filename("cyl_testdata.txt")
19        load.set_values()
20        data11 = Data1D(x=[], y=[],dx=None, dy=None)
21        load.load_data(data11)
22       
23        #Importing the Fit module
24        from sans.fit.Fitting import Fit
25        fitter= Fit('scipy')
26       
27        # Receives the type of model for the fitting
28        from sans.guitools.LineModel import LineModel
29        model1  = LineModel()
30        data1=Data(sans_data=data11)
31        model =Model(model1)
32        #Do the fit SCIPY0.007778 1.78E+14 13335629
33        v=[0.007778,0.023333,0.031111,0.038889,0.046667,0.054444]
34        for i in range(len(v)):
35            self.assertEquals(data1.x[i],v[i])
36        #fitter.set_data_assembly(data1,1)
37        #fitter.set_model_assembly(model,"M1",1,['A','B'])
38    def test_Model(self):
39        """ test Model"""
40        #load data
41        from sans.fit.Loader import Load
42        load= Load()
43        load.set_filename("cyl_testdata.txt")
44        load.set_values()
45        data11 = Data1D(x=[], y=[],dx=None, dy=None)
46        load.load_data(data11)
47       
48        #Importing the Fit module
49        from sans.fit.Fitting import Fit
50        fitter= Fit('scipy')
51       
52        # Receives the type of model for the fitting
53        from sans.models.CylinderModel import CylinderModel
54        model1  = CylinderModel()
55        data1=Data(sans_data=data11)
56        model =Model(model1)
57        for item in data1.x:
58            self.assertEquals(model.eval(item),model.model.run(item))
59        p=[0.0, 3.0000000000000001e-006, 1.0, 1.0, 400.0, 20.0, 1.0] 
60        model.setParams(p)
61        res=[]
62        for i in range(len(data1.x)):
63            res.append((data1.y[i]-model.eval(data1.x[i]))/data1.dy[i])
64            self.assertEquals(model.eval(data1.x[i]),model.model.run(data1.x[i])) 
65        print res
66    def test_funtor(self):
67        """ test functor"""
68        #load data
69        from sans.fit.Loader import Load
70        load= Load()
71        load.set_filename("cyl_testdata.txt")
72        load.set_values()
73        data11 = Data1D(x=[], y=[],dx=None, dy=None)
74        load.load_data(data11)
75       
76        #Importing the Fit module
77        from sans.fit.Fitting import Fit
78        fitter= Fit('scipy')
79       
80        # Receives the type of model for the fitting
81        from sans.models.CylinderModel import CylinderModel
82        model1  = CylinderModel()
83        data1=Data(sans_data=data11)
84        model =Model(model1)
85        functor= sansAssembly(model,data1)
86        for item in data1.x:
87            self.assertEquals(model.eval(item),model.model.run(item))
88        p=[0.0, 3.0000000000000001e-006, 1.0, 1.0, 400.0, 20.0, 1.0] 
89        model.setParams(p)
90        res=[]
91        for i in range(len(data1.x)):
92            res.append((data1.y[i]-model.eval(data1.x[i]))/data1.dy[i])
93            self.assertEquals(model.eval(data1.x[i]),model.model.run(data1.x[i])) 
94        f=functor(p)
95
96        for i in range(len(res)):
97            self.assertEquals(res[i],f[i])   
98       
Note: See TracBrowser for help on using the repository browser.