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

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 1f5f206 was 1f5f206, checked in by butler, 9 years ago

Fix sphinx compile errors with autogenerated model files. Was including
the path in doc string which for windows uses a slash which ReST
interprets as an escape charater. Was not rendering the source file
correctly for ANY of the generated but was a particular problem for
files that had an f as \f is formfeed.

  • 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   THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
20   DO NOT MODIFY THIS FILE, MODIFY
21   [INCLUDE_FILE]
22   AND RE-RUN THE GENERATOR SCRIPT
23"""
24
25from sas.models.BaseComponent import BaseComponent
26from sas.models.sas_extension.c_models import [CPYTHONCLASS]
27from numpy import inf
28
29def create_[PYTHONCLASS]():
30    """
31    Create a model instance
32    """
33    obj = [PYTHONCLASS]()
34    # [CPYTHONCLASS].__init__(obj) is called by
35    # the [PYTHONCLASS] constructor
36    return obj
37
38class [PYTHONCLASS]([CPYTHONCLASS], BaseComponent):
39    """
40    Class that evaluates a [PYTHONCLASS] model.
41    This file was auto-generated from [INCLUDE_FILE].
42    Refer to that file and the structure it contains
43    for details of the model.
44    [DEFAULT_LIST]
45    """
46
47    def __init__(self, multfactor=1):
48        """ Initialization """
49        self.__dict__ = {}
50
51        # Initialize BaseComponent first, then sphere
52        BaseComponent.__init__(self)
53        #apply([CPYTHONCLASS].__init__, (self,))
54
55        [CALL_CPYTHON_INIT]
56
57        ## Name of the model
58        self.name = "[PYTHONCLASS]"
59        ## Model description
60        self.description = """
61        [DESCRIPTION]
62        """
63
64        [PAR_DETAILS]
65        ## fittable parameters
66        self.fixed = [FIXED]
67
68        ## non-fittable parameters
69        self.non_fittable = [NON_FITTABLE_PARAMS]
70
71        ## parameters with orientation
72        self.orientation_params = [ORIENTATION_PARAMS]
73
74        ## parameters with magnetism
75        self.magnetic_params = [MAGNETIC_PARAMS]
76
77        self.category = [CATEGORY]
78        self.multiplicity_info = [MULTIPLICITY_INFO]
79
80    def __setstate__(self, state):
81        """
82        restore the state of a model from pickle
83        """
84        self.__dict__, self.params, self.dispersion = state
85
86    def __reduce_ex__(self, proto):
87        """
88        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
89        c model.
90        """
91        state = (self.__dict__, self.params, self.dispersion)
92        return (create_[PYTHONCLASS], tuple(), state, None, None)
93
94    def clone(self):
95        """ Return a identical copy of self """
96        return self._clone([PYTHONCLASS]())
97
98    def run(self, x=0.0):
99        """
100        Evaluate the model
101
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
111        :param x: input q, or [qx, qy]
112        :return: scattering function P(q)
113        """
114        return [CPYTHONCLASS].runXY(self, x)
115
116    def evalDistribution(self, x):
117        """
118        Evaluate the model in cartesian coordinates
119
120        :param x: input q[], or [qx[], qy[]]
121        :return: scattering function P(q[])
122        """
123        return [CPYTHONCLASS].evalDistribution(self, x)
124
125    def calculate_ER(self):
126        """
127        Calculate the effective radius for P(q)*S(q)
128
129        :return: the value of the effective radius
130        """
131        return [CPYTHONCLASS].calculate_ER(self)
132
133    def calculate_VR(self):
134        """
135        Calculate the volf ratio for P(q)*S(q)
136
137        :return: the value of the volf ratio
138        """
139        return [CPYTHONCLASS].calculate_VR(self)
140
141    def set_dispersion(self, parameter, dispersion):
142        """
143        Set the dispersion object for a model parameter
144
145        :param parameter: name of the parameter [string]
146        :param dispersion: dispersion object of type DispersionModel
147        """
148        return [CPYTHONCLASS].set_dispersion(self,
149               parameter, dispersion.cdisp)
150
151# End of file
Note: See TracBrowser for help on using the repository browser.