Changeset 0abf7bf in sasview


Ignore:
Timestamp:
Nov 23, 2011 1:16:37 PM (12 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
26da93f
Parents:
953fe92
Message:

Re #5 Get rid of pyre models, odb creation, and modelfactory, all of which haven't been used since 2007.

Files:
19 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/setup.py

    rd7a2531 r0abf7bf  
    11""" 
    22 Installation script for SANS models 
    3  
    4   - To compile and install: 
    5       python setup.py install 
    6   - To create distribution: 
    7       python setup.py bdist_wininst 
    8   - To create odb files: 
    9       python setup.py odb 
    10  
    113""" 
    124 
    135import sys 
    146import os 
    15  
    16      
    177from numpy.distutils.misc_util import get_numpy_include_dirs 
    188numpy_incl_path = os.path.join(get_numpy_include_dirs()[0], "numpy") 
    19  
    20 def createODBcontent(class_name): 
    21     """ 
    22         Return the content of the Pyre odb file for a given class 
    23         @param class_name: Name of the class to write an odb file for [string] 
    24         @return: content of the file [string] 
    25     """ 
    26     content  = "\"\"\"\n" 
    27     content += "  Facility for SANS model\n\n" 
    28     content += "  WARNING: THIS FILE WAS AUTOGENERATED AT INSTALL TIME\n" 
    29     content += "           DO NOT MODIFY\n\n" 
    30     content += "  This code was written as part of the DANSE project\n" 
    31     content += "  http://danse.us/trac/sans/\n" 
    32     content += "  @copyright 2007:" 
    33     content += "  SANS/DANSE Group (University of Tennessee), for the DANSE project\n\n" 
    34     content += "\"\"\"\n" 
    35     content += "def model():\n" 
    36     content += "    from ScatteringIntensityFactory import ScatteringIntensityFactory\n" 
    37     content += "    from sans.models.%s import %s\n" % (class_name, class_name) 
    38     content += "    return ScatteringIntensityFactory(%s)('%s')\n"\ 
    39                  % (class_name, class_name) 
    40  
    41     return content 
    42  
    43 def createODBfiles(): 
    44     """ 
    45        Create odb files for all available models 
    46     """ 
    47     from sans.models.ModelFactory import ModelFactory 
    48      
    49     class_list = ModelFactory().getAllModels() 
    50     for name in class_list: 
    51         odb = open("src/sans/models/pyre/%s.odb" % name, 'w') 
    52         odb.write(createODBcontent(name)) 
    53         odb.close() 
    54         print "src/sans/models/pyre/%s.odb created" % name 
    55          
    56 # 
    57 # Proceed with installation 
    58 # 
    59  
    60 # First, create the odb files 
    61 if len(sys.argv) > 1 and sys.argv[1].lower() == 'odb': 
    62     print "Creating odb files" 
    63     try: 
    64         createODBfiles() 
    65     except:     
    66         print "ERROR: could not create odb files" 
    67         print sys.exc_value 
    68     sys.exit() 
    69  
     9    
    7010# Then build and install the modules 
    7111from distutils.core import Extension, setup 
     
    13979    package_data={'sans.models': [os.path.join('media', "*")]}, 
    14080    packages = ["sans","sans.models", 
    141                 "sans.models.sans_extension","sans.models.pyre",], 
     81                "sans.models.sans_extension",], 
    14282     
    14383    ext_modules = [ Extension("sans.models.sans_extension.c_models", 
  • sansmodels/src/sans/models/DisperseModel.py

    r79ac6f8 r0abf7bf  
    2424        Example: :: 
    2525         
    26                 cyl = ModelFactory().getModel("CylinderModel") 
     26                cyl = CylinderModel() 
    2727                disp = DisperseModel(cyl, ['cyl_phi'], [0.3]) 
    2828                disp.run([0.01, 1.57]) 
  • sansmodels/src/sans/models/__init__.py

    rb1a65b6 r0abf7bf  
    4848# To create a model: 
    4949# \verbatim 
    50 #from sans.models.ModelFactory import ModelFactory 
    51 #    cyl = ModelFactory().getModel('CylinderModel') 
     50#from sans.models.CylinderModel import CylinderModel 
     51#    cyl = CylinderModel() 
    5252# \endverbatim 
    5353# 
  • sansmodels/test/SmearList.py

    r18e250c r0abf7bf  
    11 
    2 from sans.models.ModelFactory import ModelFactory 
    32from sans.models.BaseComponent import BaseComponent 
    43import math 
     
    1514         
    1615        ## Model to smear 
    17         #self.model = factory.getModel(model_name) 
    1816        self.model = model 
    1917        ## Standard deviation of the smearing 
     
    5351             
    5452            # Gaussian function used to weigh points 
    55             #gaussian = ModelFactory().getModel("Gaussian") 
    5653            gaussian = Gaussian() 
    5754            gaussian.setParam('sigma', self.sigmas[id]) 
     
    162159         
    163160        return value 
    164          
    165 # main 
    166 if __name__ == '__main__': 
    167     import math 
    168     if True: 
    169         cyl = ModelFactory().getModel("CylinderModel") 
    170         cyl.setParam('length', 2000.0) 
    171         cyl.setParam('cyl_phi', .45) 
    172         cyl.setParam('cyl_theta', 2.) 
    173         #app = Smear(cyl,['cyl_theta', 'cyl_phi'], [.01, .01]) 
    174         #app = Smear(cyl,['cyl_theta', 'cyl_phi'], [2.0, 2.0]) 
    175         #app = Smear(cyl,['cyl_theta'], [2.5]) 
    176         app = Smear(cyl, ['cyl_phi', 'cyl_theta'], [math.pi, math.pi]) 
    177         #app = Smear(cyl,['scale', 'scale'],[.5,1.0]) 
    178         val_no = cyl.run([.001, 1.0]) 
    179         print "Cylinder (no smear) f(.1):", val_no 
    180         val_sm =  app.run([.001, 1.0]) 
    181         print "Cylinder (smear)    f(.1):", val_sm, app.error, app.error/val_sm 
    182         print "Cylinder (1D)    f(.1):", cyl.run(.001), cyl.run(.001)/val_sm 
    183        
    184        
    185     print "--------------" 
    186     sinsin = ModelFactory().getModel("SinSin") 
    187     sinsin.setParam('a', -1.7) 
    188     sinsin.setParam('b', 5.45) 
    189     #app = Smear(sinsin, ['A'], [3.1]) 
    190     #app = Smear(sinsin, ['A', 'b'], [math.pi/2.0, .0]) 
    191     app = Smear(sinsin, ['A'], [math.pi/2.0]) 
    192     #app = Smear(cyl,['scale', 'scale'],[.5,1.0]) 
    193     val_no = sinsin.run(1.0) 
    194     print "SinSin (no smear) :", val_no 
    195     val_sm =  app.run(1.0) 
    196     print "SinSin (smear)    : %g +- %g" % (val_sm, app.error) 
    197        
  • sansmodels/test/utest_disperser.py

    r77220ee r0abf7bf  
    1515 
    1616from sans.models.sans_extension.c_models import Disperser 
    17 from sans.models.ModelFactory import ModelFactory 
     17from sans.models.CylinderModel import CylinderModel 
    1818from sans.models.DisperseModel import DisperseModel 
    1919       
     
    2222     
    2323    def setUp(self): 
    24         self.model = ModelFactory().getModel("CylinderModel") 
     24        self.model = CylinderModel() 
    2525        self.model.setParam("cyl_theta", 1.57) 
    2626        self.model.setParam("cyl_phi", 0.1) 
     
    8484     
    8585    def setUp(self): 
    86         self.model = ModelFactory().getModel("CylinderModel") 
     86        self.model = CylinderModel() 
    8787        self.model.setParam("cyl_theta", 1.57) 
    8888        self.model.setParam("cyl_phi", 0.1) 
  • sansmodels/test/utest_models.py

    r18e250c r0abf7bf  
    6363        self.comp.setParam('cyl_phi', 1*180/math.pi) 
    6464        self.assertAlmostEqual(self.comp.run([0.2, 2.5]),  
    65                                0.038176446608393366, 4) 
    66         
    67     def testIO(self): 
    68         from sans.models.ModelFactory import ModelFactory 
    69         from sans.models.ModelIO import ModelIO 
    70         factory = ModelFactory() 
    71         io = ModelIO(factory) 
    72         io.save(self.comp,"myModel.xml") 
    73         value = self.comp.run(1) 
    74         loaded = io.load("myModel.xml") 
    75         self.assertEqual(value, loaded.run(1)) 
    76          
    77     def testIO_add(self): 
    78         # version 0.5.0: No longer supported 
    79         return 
    80         from sans.models.ModelFactory import ModelFactory 
    81         from sans.models.ModelIO import ModelIO 
    82         factory = ModelFactory() 
    83         io = ModelIO(factory) 
    84         sph = factory.getModel("SphereModel") 
    85         cyl = factory.getModel("CylinderModel") 
    86         combo = sph - cyl 
    87         io.save(combo,"myModel.xml") 
    88         value = combo.run(1) 
    89         loaded = io.load("myModel.xml") 
    90         self.assertEqual(value, loaded.run(1)) 
    91          
    92     def testIO_add2(self): 
    93         # version 0.5.0: No longer supported 
    94         return 
    95         from sans.models.ModelFactory import ModelFactory 
    96         #from sans.models.ModelIO import ModelIO 
    97         factory = ModelFactory() 
    98         #io = ModelIO(factory) 
    99         sph = factory.getModel("SphereModel") 
    100         cyl = factory.getModel("CylinderModel") 
    101         sph2 = factory.getModel("SphereModel") 
    102         combo1 = cyl - sph 
    103         combo = combo1 / sph2 
    104         #combo1 = sph 
    105         #io.save(combo,"myModel.xml") 
    106         # Just check that we have some output 
    107         self.assertTrue(math.fabs(combo.run(1))>0) 
    108         #loaded = io.load("myModel.xml") 
    109         #self.assertEqual(value, loaded.run(1)) 
    110          
    111          
    112        
    113         
    114 class TestFactory(unittest.TestCase): 
    115     """Unit tests for Model Factory""" 
    116      
    117     def setUp(self): 
    118         from sans.models.ModelFactory import ModelFactory 
    119         self.comp = ModelFactory().getModel('CylinderModel') 
    120          
    121     def test1D(self): 
    122         """ Test 1D model of a cylinder """  
    123         self.assertAlmostEqual(self.comp.run(0.2), 0.041761386790780453, 4) 
    124          
     65                               0.038176446608393366, 4)  
    12566  
    12667class TestGaussian(unittest.TestCase): 
  • sansmodels/test/validate_1D_model.py

    r18e250c r0abf7bf  
    2525            @param filename: name of the test data set 
    2626        """ 
    27         from sans.models.ModelFactory import ModelFactory 
     27        from sans.models.CylinderModel import CylinderModel 
    2828         
    2929        # Read the data file 
     
    4646                    print "Found class", toks[1] 
    4747                    classname = toks[1].lstrip().rstrip() 
    48                     model_object = ModelFactory().getModel(classname) 
     48                    exec "from sans.models.%s import %s" % (classname, classname) 
     49                    exec "model_object = %s()" % classname 
    4950                 
    5051                    # Output file for plotting 
Note: See TracChangeset for help on using the changeset viewer.