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 d831626 was
48882d1,
checked in by Gervaise Alina <gervyh@…>, 16 years ago
|
park fitting with new model and new data
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | """ |
---|
2 | Unit tests for fitting module |
---|
3 | """ |
---|
4 | import unittest |
---|
5 | from sans.guitools.plottables import Theory1D |
---|
6 | from sans.guitools.plottables import Data1D |
---|
7 | from sans.fit.AbstractFitEngine import Data, Model |
---|
8 | import math |
---|
9 | class 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('scipy') |
---|
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_assembly(data1,1) |
---|
34 | fitter.set_model_assembly(model,"M1",1,['A','B']) |
---|
35 | |
---|
36 | result=fitter.fit() |
---|
37 | print "scipy",result.pvec, |
---|
38 | chisqr1, out1, cov1=fitter.fit() |
---|
39 | """ testing SCIPy results""" |
---|
40 | self.assert_(math.fabs(out1[1]-2.5)/math.sqrt(cov1[1][1]) < 2) |
---|
41 | self.assert_(math.fabs(out1[0]-4.0)/math.sqrt(cov1[0][0]) < 2) |
---|
42 | self.assert_(chisqr1/len(data1.x) < 2) |
---|
43 | |
---|
44 | |
---|
Note: See
TracBrowser
for help on using the repository browser.