source: sasview/sansmodels/src/sans/models/DivComponent.py @ 829eee9

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

Moving sansmodels to trunk

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