source: sasview/sansmodels/src/python_wrapper/modelTemplate.txt @ 1e62361

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 1e62361 was 5625551, checked in by Mathieu Doucet <doucetm@…>, 13 years ago

Fixing code style problems and bugs

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