source: sasview/sansmodels/src/sans/models/ModelAdaptor.py @ 277aab4e

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 277aab4e was 5f89fb8, checked in by Gervaise Alina <gervyh@…>, 16 years ago

description field added in models not filled yet

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#!/usr/bin/env python
2"""
3    This software was developed by the University of Tennessee as part of the
4    Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
5    project funded by the US National Science Foundation.
6
7    If you use DANSE applications to do scientific research that leads to
8    publication, we ask that you acknowledge the use of the software with the
9    following sentence:
10
11    "This work benefited from DANSE software developed under NSF award DMR-0520547."
12
13    copyright 2008, University of Tennessee
14"""
15
16"""
17    Provide base functionality for all model components
18   
19    The following has changed since going from BaseComponent to BaseModel:
20   
21        - Arithmetic operation between models is no longer supported.
22          It was found to be of little use and not very flexible.
23       
24        - Parameters are now stored as Parameter object to provide
25          the necessary extra information like limits, units, etc...
26"""
27
28class ParameterDict(dict):
29    """
30        Parameter dictionary used for backward
31        compatibility between the old-style 'params'
32        dictionary and the new-style 'parameters'
33        dictionary.
34    """
35    def __init__(self, parameters):
36        """   
37            Initialization
38            @param parameters: new-style 'parameters' dictionary
39        """
40        self.parameters = parameters
41       
42    def __setitem__(self, name, value):
43        self.parameters[name].value = value
44   
45    def __getitem__(self, name):
46        return self.parameters[name].value
47   
48class ModelAdaptor(object):
49    """
50        Model adaptor to provide old-style model functionality
51    """
52
53    def __init__(self):
54        """ Initialization"""
55        ## Dictionary of Parameter objects
56        self.parameters = {}
57        ## Dictionary of parameters, available for backward compatibility
58        self.params = ParameterDict(self.parameters)
59        ## Additional details, provided for backward compatibility
60        self.details = {}
61        self.description=''
62        ## Dictionary used to store the dispersity/averaging
63        #  parameters of dispersed/averaged parameters.
64        ## Provided for backward compatibility
65        self.dispersion = {}
66                             
67    # Old-style methods that are no longer used
68    def setParamWithToken(self, name, value, token, member): return NotImplemented
69    def getParamWithToken(self, name, token, member): return NotImplemented
70    def getParamListWithToken(self, token, member): return NotImplemented
71    def __add__(self, other): raise ValueError, "Model operation are no longer supported"
72    def __sub__(self, other): raise ValueError, "Model operation are no longer supported"
73    def __mul__(self, other): raise ValueError, "Model operation are no longer supported"
74    def __div__(self, other): raise ValueError, "Model operation are no longer supported"
75
76   
77
78if __name__ == "__main__":
79    b = BaseModel() 
80    print b.operateOn
81   
Note: See TracBrowser for help on using the repository browser.