source: sasview/src/sas/models/ModelAdaptor.py @ 686fd10

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 686fd10 was 79492222, checked in by krzywon, 10 years ago

Changed the file and folder names to remove all SANS references.

  • Property mode set to 100644
File size: 3.4 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    def __init__(self):
53        """ Initialization"""
54        ## Dictionary of Parameter objects
55        self.parameters = {}
56        ## Dictionary of parameters, available for backward compatibility
57        self.params = ParameterDict(self.parameters)
58        ## Additional details, provided for backward compatibility
59        self.details = {}
60        self.description = ''
61        ## Dictionary used to store the dispersity/averaging
62        #  parameters of dispersed/averaged parameters.
63        ## Provided for backward compatibility
64        self.dispersion = {}
65                             
66    # Old-style methods that are no longer used
67    def setParamWithToken(self, name, value, token, member): 
68        """
69        set Param With Token
70        """
71        return NotImplemented
72   
73    def getParamWithToken(self, name, token, member): 
74        """
75        get Param With Token
76        """
77        return NotImplemented
78   
79    def getParamListWithToken(self, token, member): 
80        """
81        get Param List With Token
82        """
83        return NotImplemented
84    def __add__(self, other): 
85        """
86        add
87        """
88        raise ValueError, "Model operation are no longer supported"
89    def __sub__(self, other): 
90        """
91        sub
92        """
93        raise ValueError, "Model operation are no longer supported"
94    def __mul__(self, other): 
95        """
96        mul
97        """
98        raise ValueError, "Model operation are no longer supported"
99    def __div__(self, other): 
100        """
101        div
102        """
103        raise ValueError, "Model operation are no longer supported"
104
105if __name__ == "__main__":
106    b = ModelAdaptor() 
107    #print b.operateOn
108   
Note: See TracBrowser for help on using the repository browser.