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

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 f994d7cd was c93122e, checked in by Doucet, Mathieu <doucetm@…>, 10 years ago

Pylint for model template

  • Property mode set to 100644
File size: 4.4 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        :param x: input q, or [q,phi]
103        :return: scattering function P(q)
104        """
105        return [CPYTHONCLASS].run(self, x)
106
107    def runXY(self, x=0.0):
108        """
109        Evaluate the model in cartesian coordinates
110        :param x: input q, or [qx, qy]
111        :return: scattering function P(q)
112        """
113        return [CPYTHONCLASS].runXY(self, x)
114
115    def evalDistribution(self, x):
116        """
117        Evaluate the model in cartesian coordinates
118        :param x: input q[], or [qx[], qy[]]
119        :return: scattering function P(q[])
120        """
121        return [CPYTHONCLASS].evalDistribution(self, x)
122
123    def calculate_ER(self):
124        """
125        Calculate the effective radius for P(q)*S(q)
126        :return: the value of the effective radius
127        """
128        return [CPYTHONCLASS].calculate_ER(self)
129
130    def calculate_VR(self):
131        """
132        Calculate the volf ratio for P(q)*S(q)
133        :return: the value of the volf ratio
134        """
135        return [CPYTHONCLASS].calculate_VR(self)
136
137    def set_dispersion(self, parameter, dispersion):
138        """
139        Set the dispersion object for a model parameter
140        :param parameter: name of the parameter [string]
141        :param dispersion: dispersion object of type DispersionModel
142        """
143        return [CPYTHONCLASS].set_dispersion(self,
144               parameter, dispersion.cdisp)
145
146# End of file
Note: See TracBrowser for help on using the repository browser.