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

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

Fixed new models - still need validation

  • Property mode set to 100644
File size: 2.2 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 runXY(self, x=0):
41        """
42            Evaluate each part of the component and sum the results
43            @param x: input parameter
44            @return: value of the model at x
45        """
46        return self.operateOn.runXY(x) / self.other.runXY(x)
47       
48    def setParam(self, name, value):
49        """
50            Set the value of a model parameter
51            @param name: name of parameter to set
52            @param value: value to give the paramter
53        """
54        return BaseComponent.setParamWithToken(self, name, 
55                                               value, 'div', self.other)
56   
57    def getParam(self, name):
58        """
59            Set the value of a model parameter
60            @param name: name of the parameter
61            @return: value of the parameter
62        """
63        return BaseComponent.getParamWithToken(self, name, 'div', self.other)
64   
65    def getParamList(self):
66        """ Return a list of all available parameters for the model
67        """
68        return BaseComponent.getParamListWithToken(self, 'div', self.other)
69   
70# End of file
Note: See TracBrowser for help on using the repository browser.