Changeset 386ffe1 in sasview for test


Ignore:
Timestamp:
Feb 20, 2015 5:02:38 AM (9 years ago)
Author:
pkienzle
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
cda1cf8
Parents:
018582f
Message:

remove scipy levenburg marquardt and park from ui

Location:
test
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • test/park_integration/test/batch_fit.py

    r35ec279 r386ffe1  
    4242        self.qmax = qmax 
    4343         
    44     def _reset_helper(self, path=None, engine="scipy", npts=NPTS): 
     44    def _reset_helper(self, path=None, engine="bumps", npts=NPTS): 
    4545        """ 
    4646        Set value to fitter engine and prepare inputs for map function 
     
    7777            self.list_of_mapper.append(classMapper) 
    7878                    
    79     def reset_value(self, engine='scipy'): 
     79    def reset_value(self, engine='bumps'): 
    8080        """ 
    8181        Initialize inputs for the map function 
  • test/park_integration/test/utest_fit_cylinder.py

    ra10364b r386ffe1  
    2727        self.pars1 =['length','radius','scale'] 
    2828         
    29     def _fit(self, name="scipy"): 
     29    def _fit(self, name="bumps"): 
    3030        """ return fit result """ 
    3131        fitter = Fit(name) 
     
    4545 
    4646 
    47     def test_scipy(self): 
    48         """ Simple cylinder model fit (scipy)  """ 
    49         self._fit("scipy") 
    50  
    51  
    52     def test_park(self): 
    53         """ Simple cylinder model fit (park)  """ 
    54         self._fit("park") 
    55  
    5647    def test_bumps(self): 
    57         """ Simple cylinder model fit (park)  """ 
     48        """ Simple cylinder model fit """ 
    5849        self._fit("bumps") 
    5950 
     
    9081 
    9182    def test_constrained_bumps(self): 
    92         """ Simultaneous cylinder model fit (park) """ 
     83        """ Simultaneous cylinder model fit """ 
    9384        self._run_fit(Fit('bumps')) 
    9485 
    9586    #@unittest.skip("") 
    96     def test_constrained_park(self): 
    97         """ Simultaneous cylinder model fit (park)  """ 
    98         self._run_fit(Fit('park')) 
    99  
    10087    def _run_fit(self, fitter): 
    10188        result1, result2 = self._fit(fitter) 
     
    10592 
    10693        for n, v, dv in zip(result1.param_list, result1.pvec, result1.stderr): 
    107             print "%s M1.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 
     94            #print "%s M1.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 
    10895            if n == "length": 
    10996                self.assertTrue( math.fabs(v-400.0)/3.0 < dv ) 
     
    113100                self.assertTrue( math.fabs(v-1.0)/3.0 < dv ) 
    114101        for n, v, dv in zip(result2.param_list, result2.pvec, result2.stderr): 
    115             print "%s M2.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 
     102            #print "%s M2.%s = %s +/- %s"%(fitter._engine.__class__.__name__,n,v,dv) 
    116103            if n=='radius': 
    117104                self.assertTrue( math.fabs(v-40.0)/3.0 < dv ) 
  • test/park_integration/test/utest_fit_line.py

    r35ec279 r386ffe1  
    3232            assert str(exc).startswith('parameter param1') 
    3333        else: 
    34             raise AssertionError("No error raised for scipy fitting with wrong parameters name to fit") 
     34            raise AssertionError("No error raised for fitting with wrong parameters name to fit") 
    3535 
    3636    def fit_single(self, fitter_name, isdream=False): 
     
    4545        model1.name = "M1" 
    4646        model = Model(model1,data) 
    47         #fit with scipy test 
    4847 
    4948        pars1= ['A','B'] 
     
    9291        self.fit_bumps('lm') 
    9392 
    94     def test_scipy(self): 
    95         #print "fitting scipy" 
    96         self.fit_single('scipy') 
    97  
    98     def test_park(self): 
    99         #print "fitting park" 
    100         self.fit_single('park') 
    101  
    102          
    10393    def test2(self): 
    10494        """ fit 2 data and 2 model with no constrainst""" 
     
    112102      
    113103        #Importing the Fit module 
    114         fitter = Fit('scipy') 
     104        fitter = Fit('bumps') 
    115105        # Receives the type of model for the fitting 
    116106        model11  = LineModel() 
     
    121111        model1 = Model(model11,data1) 
    122112        model2 = Model(model22,data2) 
    123         #fit with scipy test 
    124113        pars1= ['A','B'] 
    125114        fitter.set_data(data1,1) 
     
    129118        fitter.set_model(model2,2,pars1) 
    130119        fitter.select_problem_for_fit(id=2,value=0) 
    131          
     120 
    132121        try: result1, = fitter.fit(handler=FitHandler()) 
    133122        except RuntimeError,msg: 
    134            assert str(msg)=="No Assembly scheduled for Scipy fitting." 
    135         else: raise AssertionError,"No error raised for scipy fitting with no model" 
    136         fitter.select_problem_for_fit(id=1,value=1) 
    137         fitter.select_problem_for_fit(id=2,value=1) 
    138         try: result1, = fitter.fit(handler=FitHandler()) 
    139         except RuntimeError,msg: 
    140            assert str(msg)=="Scipy can't fit more than a single fit problem at a time." 
    141         else: raise AssertionError,"No error raised for scipy fitting with more than 2 models" 
    142  
    143         #fit with park test 
    144         fitter = Fit('park') 
    145         fitter.set_data(data1,1) 
    146         fitter.set_model(model1,1,pars1) 
    147         fitter.set_data(data2,2) 
    148         fitter.set_model(model2,2,pars1) 
     123            assert str(msg)=="Nothing to fit" 
     124        else: raise AssertionError,"No error raised for fitting with no model" 
    149125        fitter.select_problem_for_fit(id=1,value=1) 
    150126        fitter.select_problem_for_fit(id=2,value=1) 
     
    156132         
    157133         
    158     def test3(self): 
     134    def test_constraints(self): 
    159135        """ fit 2 data and 2 model with 1 constrainst""" 
    160136        #load data 
     
    180156        model1.set(B=3) 
    181157        # Constraint the constant value to be equal to parameter B (the real value is 2.5) 
    182         model2.set(value='line.B') 
    183         #fit with scipy test 
     158        #model2.set(value='line.B') 
    184159        pars1= ['A','B'] 
    185160        pars2= ['value'] 
    186161         
    187162        #Importing the Fit module 
    188         fitter = Fit('park') 
     163        fitter = Fit('bumps') 
    189164        fitter.set_data(data1,1) 
    190165        fitter.set_model(model1,1,pars1) 
    191166        fitter.set_data(data2,2,smearer=None) 
    192         fitter.set_model(model2,2,pars2) 
     167        fitter.set_model(model2,2,pars2,constraints=[("value","line.B")]) 
    193168        fitter.select_problem_for_fit(id=1,value=1) 
    194169        fitter.select_problem_for_fit(id=2,value=1) 
     
    216191        model = Model(model1,data1) 
    217192       
    218         #fit with scipy test 
    219         pars1= ['A','B'] 
    220         #Importing the Fit module 
    221         fitter = Fit('scipy') 
    222         fitter.set_data(data1,1,qmin=0, qmax=7) 
    223         fitter.set_model(model,1,pars1) 
    224         fitter.set_data(data2,1,qmin=1,qmax=10) 
    225         fitter.select_problem_for_fit(id=1,value=1) 
    226          
    227         result1, = fitter.fit(handler=FitHandler()) 
    228         #print(result1) 
    229         self.assert_(result1) 
    230  
    231         self.assertTrue( math.fabs(result1.pvec[0]-4)/3 <= result1.stderr[0] ) 
    232         self.assertTrue( math.fabs(result1.pvec[1]-2.5)/3 <= result1.stderr[1]) 
    233         self.assertTrue( result1.fitness/len(data1.x) < 2 ) 
    234  
    235         #fit with park test 
    236         fitter = Fit('park') 
     193        pars1= ['A','B'] 
     194        #Importing the Fit module 
     195 
     196        fitter = Fit('bumps') 
    237197        fitter.set_data(data1,1,qmin=0, qmax=7) 
    238198        fitter.set_model(model,1,pars1) 
     
    245205        self.assertTrue( math.fabs(result2.pvec[1]-2.5)/3 <= result2.stderr[1] ) 
    246206        self.assertTrue( result2.fitness/len(data1.x) < 2) 
    247         # compare fit result result for scipy and park 
    248         self.assertAlmostEquals( result1.pvec[0], result2.pvec[0] ) 
    249         self.assertAlmostEquals( result1.pvec[1],result2.pvec[1] ) 
    250         self.assertAlmostEquals( result1.stderr[0],result2.stderr[0] ) 
    251         self.assertAlmostEquals( result1.stderr[1],result2.stderr[1] ) 
    252         self.assertTrue( result2.fitness/(len(data2.x)+len(data1.x)) < 2 ) 
    253207 
    254208 
  • test/park_integration/test/utest_fit_smeared.py

    r35ec279 r386ffe1  
    1717    """ test fitting """ 
    1818     
    19     def test_scipy(self): 
    20         """ Simple cylinder model fit (scipy) """ 
     19    def test_without_resolution(self): 
     20        """ Simple cylinder model fit """ 
    2121         
    2222        out=Loader().load("cyl_400_20.txt") 
     
    2424        #out.dy = out.y 
    2525         
    26         fitter = Fit('scipy') 
     26        fitter = Fit('bumps') 
    2727        fitter.set_data(out,1) 
    2828         
     
    5353        self.assertTrue( result1.fitness < 1.0 ) 
    5454 
    55     def test_park_dispersion(self): 
    56         """ 
    57             Cylinder fit with dispersion 
    58         """ 
    59         self._dispersion(fitter = Fit('park')) 
    60  
    61     def test_bumps_dispersion(self): 
     55    def test_dispersion(self): 
    6256        """ 
    6357            Cylinder fit with dispersion 
     
    6963        fitters.FIT_OPTIONS[alg].options.update(monitors=[]) 
    7064        self._dispersion(fitter = Fit('bumps')) 
    71  
    72     def test_scipy_dispersion(self): 
    73         """ 
    74             Cylinder fit with dispersion 
    75         """ 
    76         self._dispersion(fitter = Fit('scipy')) 
    7765 
    7866    def _dispersion(self, fitter): 
     
    148136 
    149137        # Fit 
    150         fitter = Fit('scipy') 
     138        fitter = Fit('bumps') 
    151139         
    152140        # Data: right now this is the only way to set the smearer object 
     
    179167        self.assertEqual(smear.__class__.__name__, 'SlitSmearer') 
    180168 
    181         fitter = Fit('scipy') 
     169        fitter = Fit('bumps') 
    182170         
    183171        # Data: right now this is the only way to set the smearer object 
  • test/park_integration/test/utest_small_test.py

    r35ec279 r386ffe1  
    66from sas.fit.Fitting import Fit 
    77from sas.dataloader.loader import Loader 
     8import bumps.fitters 
     9bumps.fitters.FIT_DEFAULT = 'lm' 
    810 
    911class testFitModule(unittest.TestCase): 
    1012    """ test fitting """ 
    11     def test_park(self): 
    12         """ Simple cylinder model fit (scipy)  """ 
     13    def test_cylinder_fit(self): 
     14        """ Simple cylinder model fit """ 
    1315         
    1416        out= Loader().load("cyl_400_20.txt") 
    1517        
    16         fitter = Fit('scipy') 
     18        fitter = Fit('bumps') 
    1719        # Receives the type of model for the fitting 
    1820        from sas.models.CylinderModel import CylinderModel 
     
    2022        model.setParam('sldCyl', 1) 
    2123        model.setParam('sldSolv', 0) 
     24        model.setParam('scale', 1e-10) 
    2225 
    2326        pars1 =['length','radius','scale'] 
    2427        fitter.set_data(out,1) 
    25         model.setParam('scale', 1e-10) 
    2628        fitter.set_model(model,1,pars1, constraints=()) 
    2729        fitter.select_problem_for_fit(id=1,value=1) 
     
    3335        self.assertTrue(len(result1.pvec)>0 or len(result1.pvec)==0 ) 
    3436        self.assertTrue(len(result1.stderr)> 0 or len(result1.stderr)==0) 
    35          
    36         #print result1.pvec[0]-400.0, result1.pvec[0] 
    37         #print math.fabs(result1.pvec[0]-400.0)/3.0 
     37 
    3838        self.assertTrue( math.fabs(result1.pvec[0]-400.0)/3.0 < result1.stderr[0] ) 
    3939        self.assertTrue( math.fabs(result1.pvec[1]-20.0)/3.0  < result1.stderr[1] ) 
  • test/pr_inversion/test/test_output.txt

    r400155b r386ffe1  
    33#alpha=0.0007 
    44#chi2=836.797 
    5 #elapsed=0 
     5#elapsed=0.00100017 
    66#qmin=None 
    77#qmax=None 
  • test/sasmodels/test/utest_models.py

    r8c9ffde r386ffe1  
    5959      
    6060    def test2D(self): 
    61         """ Test 2D model of a cylinder """  
     61        """ Test 2D model of a cylinder """ 
    6262        self.comp.setParam('cyl_theta', 10.0) 
    6363        self.comp.setParam('cyl_phi', 10.0) 
    64         self.assertAlmostEqual(self.comp.run([0.2, 2.5]),  
    65                                0.038176446608393366, 2)  
     64        self.assertAlmostEqual(self.comp.run([0.2, 2.5]), 
     65                               0.038176446608393366, 2) 
    6666  
    6767class TestGaussian(unittest.TestCase): 
Note: See TracChangeset for help on using the changeset viewer.