source: sasview/sansmodels/src/sans/models/AddComponent.py @ 318b5bbb

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 318b5bbb was 79ac6f8, checked in by Gervaise Alina <gervyh@…>, 15 years ago

working on documentation

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#!/usr/bin/env python
2
3"""
4Provide base functionality for all model components
5
6:author: Mathieu Doucet / UTK
7
8:contact: mathieu.doucet@nist.gov
9
10"""
11
12# info
13__author__ = "Mathieu Doucet /  UTK"
14__id__ = "$Id: BaseComponent.py,v 1.2 2007/03/14 21:04:40 doucet Exp $"
15   
16# imports   
17from sans.models.BaseComponent import BaseComponent
18
19class AddComponent(BaseComponent):
20    """
21    Basic model component for Addition
22    Provides basic arithmetics
23    """
24
25    def __init__(self, base=None, other=None):
26        """
27        :param base: component to add to
28        :param other: component to add
29       
30        """
31        BaseComponent.__init__(self)
32        # Component to add to
33        self.operateOn = base
34        # Component to add
35        self.other = other
36        # name
37        self.name = 'AddComponent'
38       
39    def run(self, x=0):
40        """
41        Evaluate each part of the component and sum the results
42       
43        :param x: input parameter
44       
45        :return: value of the model at x
46       
47        """
48        return self.operateOn.run(x) + self.other.run(x)
49       
50    def runXY(self, x=0):
51        """
52        Evaluate each part of the component and sum the results
53       
54        :param x: input parameter
55       
56        :return: value of the model at x
57       
58        """
59        return self.operateOn.runXY(x) + self.other.runXY(x)
60       
61    def setParam(self, name, value):
62        """
63        Set the value of a model parameter
64       
65        :param name: name of parameter to set
66        :param value: value to give the paramter
67       
68        """
69        return BaseComponent.setParamWithToken(self, name, 
70                                               value, 'add', self.other)
71   
72    def getParam(self, name):
73        """
74        Set the value of a model parameter
75       
76        :param name: name of the parameter
77       
78        :return: value of the parameter
79       
80        """
81        return BaseComponent.getParamWithToken(self, name, 'add', self.other)
82   
83    def getParamList(self):
84        """
85        Return a list of all available parameters for the model
86        """
87        return BaseComponent.getParamListWithToken(self, 'add', self.other)
88       
89   
90# End of file
Note: See TracBrowser for help on using the repository browser.