source: sasview/src/sas/models/c_extension/python_wrapper/modelTemplate.txt @ cd06a5f

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 cd06a5f was 8836849, checked in by pkienzle, 10 years ago

Allow inf for default parameter bounds (closes #330)

  • Property mode set to 100644
File size: 4.7 KB
Line 
1##############################################################################
2# This software was developed by the University of Tennessee as part of the
3# Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
4# project funded by the US National Science Foundation.
5#
6# If you use DANSE applications to do scientific research that leads to
7# publication, we ask that you acknowledge the use of the software with the
8# following sentence:
9#
10# This work benefited from DANSE software developed under NSF award DMR-0520547
11#
12# Copyright 2008-2011, University of Tennessee
13##############################################################################
14
15"""
16Provide functionality for a C extension model
17
18.. WARNING::
19
20   THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
21   DO NOT MODIFY THIS FILE, MODIFY
22   [INCLUDE_FILE]
23   AND RE-RUN THE GENERATOR SCRIPT
24"""
25
26from sas.models.BaseComponent import BaseComponent
27from sas.models.sas_extension.c_models import [CPYTHONCLASS]
28from numpy import inf
29
30def create_[PYTHONCLASS]():
31    """
32       Create a model instance
33    """
34    obj = [PYTHONCLASS]()
35    # [CPYTHONCLASS].__init__(obj) is called by
36    # the [PYTHONCLASS] constructor
37    return obj
38
39class [PYTHONCLASS]([CPYTHONCLASS], BaseComponent):
40    """
41    Class that evaluates a [PYTHONCLASS] model.
42    This file was auto-generated from [INCLUDE_FILE].
43    Refer to that file and the structure it contains
44    for details of the model.
45    [DEFAULT_LIST]
46    """
47       
48    def __init__(self, multfactor=1):
49        """ Initialization """
50        self.__dict__ = {}
51       
52        # Initialize BaseComponent first, then sphere
53        BaseComponent.__init__(self)
54        #apply([CPYTHONCLASS].__init__, (self,))
55
56        [CALL_CPYTHON_INIT]
57                       
58        ## Name of the model
59        self.name = "[PYTHONCLASS]"
60        ## Model description
61        self.description = """
62        [DESCRIPTION]
63        """
64       
65        [PAR_DETAILS]
66        ## fittable parameters
67        self.fixed = [FIXED]
68       
69        ## non-fittable parameters
70        self.non_fittable = [NON_FITTABLE_PARAMS]
71       
72        ## parameters with orientation
73        self.orientation_params = [ORIENTATION_PARAMS]
74
75        ## parameters with magnetism
76        self.magnetic_params = [MAGNETIC_PARAMS]
77
78        self.category = [CATEGORY]
79        self.multiplicity_info = [MULTIPLICITY_INFO]
80       
81    def __setstate__(self, state):
82        """
83        restore the state of a model from pickle
84        """
85        self.__dict__, self.params, self.dispersion = state
86       
87    def __reduce_ex__(self, proto):
88        """
89        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
90        c model.
91        """
92        state = (self.__dict__, self.params, self.dispersion)
93        return (create_[PYTHONCLASS], tuple(), state, None, None)
94       
95    def clone(self):
96        """ Return a identical copy of self """
97        return self._clone([PYTHONCLASS]())   
98       
99    def run(self, x=0.0):
100        """
101        Evaluate the model
102       
103        :param x: input q, or [q,phi]
104       
105        :return: scattering function P(q)
106       
107        """
108        return [CPYTHONCLASS].run(self, x)
109   
110    def runXY(self, x=0.0):
111        """
112        Evaluate the model in cartesian coordinates
113       
114        :param x: input q, or [qx, qy]
115       
116        :return: scattering function P(q)
117       
118        """
119        return [CPYTHONCLASS].runXY(self, x)
120       
121    def evalDistribution(self, x):
122        """
123        Evaluate the model in cartesian coordinates
124       
125        :param x: input q[], or [qx[], qy[]]
126       
127        :return: scattering function P(q[])
128       
129        """
130        return [CPYTHONCLASS].evalDistribution(self, x)
131       
132    def calculate_ER(self):
133        """
134        Calculate the effective radius for P(q)*S(q)
135       
136        :return: the value of the effective radius
137       
138        """       
139        return [CPYTHONCLASS].calculate_ER(self)
140       
141    def calculate_VR(self):
142        """
143        Calculate the volf ratio for P(q)*S(q)
144       
145        :return: the value of the volf ratio
146       
147        """       
148        return [CPYTHONCLASS].calculate_VR(self)
149             
150    def set_dispersion(self, parameter, dispersion):
151        """
152        Set the dispersion object for a model parameter
153       
154        :param parameter: name of the parameter [string]
155        :param dispersion: dispersion object of type DispersionModel
156       
157        """
158        return [CPYTHONCLASS].set_dispersion(self,
159               parameter, dispersion.cdisp)
160       
161   
162# End of file
Note: See TracBrowser for help on using the repository browser.