source: sasview/sansmodels/src/sans/models/Constant.py @ e71440c

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 e71440c was ae3ce4e, checked in by Mathieu Doucet <doucetm@…>, 17 years ago

Moving sansmodels to trunk

  • Property mode set to 100644
File size: 1.3 KB
Line 
1#!/usr/bin/env python
2""" Provide constant function as a BaseComponent model
3"""
4
5from sans.models.BaseComponent import BaseComponent
6import copy
7
8class Constant(BaseComponent):
9    """ Class that evaluates a constant model.
10        List of default parameters:
11         value           = 1.0
12    """
13       
14    def __init__(self):
15        """ Initialization """
16       
17        # Initialize BaseComponent first, then sphere
18        BaseComponent.__init__(self)
19       
20        ## Name of the model
21        self.name = "Constant"
22
23        ## Parameter details [units, min, max]
24        self.details = {}
25        self.details['value'] = ['', None, None]
26        self.params['value'] = 1.0
27   
28    def clone(self):
29        """ Return a identical copy of self """
30        obj = Constant()
31        obj.params = copy.deepcopy(self.params)
32        return obj   
33   
34    def run(self, x = 0.0):
35        """ Evaluate the model
36            @param x: unused
37            @return: (constant value)
38        """
39        return self.params['value']
40   
41    def runXY(self, x = 0.0):
42        """ Evaluate the model
43            @param x: unused
44            @return: constant value
45        """
46        return self.params['value']
47   
48# End of file
Note: See TracBrowser for help on using the repository browser.