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

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 6f17afa 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
RevLine 
[fd5ac0d]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
[c93122e]15"""
[fd5ac0d]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]
[8836849]27from numpy import inf
[fd5ac0d]28
29def create_[PYTHONCLASS]():
30    """
[1f5f206]31    Create a model instance
[fd5ac0d]32    """
33    obj = [PYTHONCLASS]()
34    # [CPYTHONCLASS].__init__(obj) is called by
35    # the [PYTHONCLASS] constructor
36    return obj
37
38class [PYTHONCLASS]([CPYTHONCLASS], BaseComponent):
[c93122e]39    """
40    Class that evaluates a [PYTHONCLASS] model.
[fd5ac0d]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    """
[c93122e]46
[fd5ac0d]47    def __init__(self, multfactor=1):
48        """ Initialization """
49        self.__dict__ = {}
[c93122e]50
[fd5ac0d]51        # Initialize BaseComponent first, then sphere
52        BaseComponent.__init__(self)
53        #apply([CPYTHONCLASS].__init__, (self,))
54
55        [CALL_CPYTHON_INIT]
[c93122e]56
[fd5ac0d]57        ## Name of the model
58        self.name = "[PYTHONCLASS]"
59        ## Model description
60        self.description = """
61        [DESCRIPTION]
62        """
[c93122e]63
[fd5ac0d]64        [PAR_DETAILS]
65        ## fittable parameters
66        self.fixed = [FIXED]
[c93122e]67
[fd5ac0d]68        ## non-fittable parameters
69        self.non_fittable = [NON_FITTABLE_PARAMS]
[c93122e]70
[fd5ac0d]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]
[c93122e]79
[fd5ac0d]80    def __setstate__(self, state):
81        """
82        restore the state of a model from pickle
83        """
84        self.__dict__, self.params, self.dispersion = state
[c93122e]85
[fd5ac0d]86    def __reduce_ex__(self, proto):
87        """
[c93122e]88        Overwrite the __reduce_ex__ of PyTypeObject *type call in the init of
[fd5ac0d]89        c model.
90        """
91        state = (self.__dict__, self.params, self.dispersion)
92        return (create_[PYTHONCLASS], tuple(), state, None, None)
[c93122e]93
[fd5ac0d]94    def clone(self):
95        """ Return a identical copy of self """
[c93122e]96        return self._clone([PYTHONCLASS]())
97
[fd5ac0d]98    def run(self, x=0.0):
[c93122e]99        """
[fd5ac0d]100        Evaluate the model
[1f5f206]101
[fd5ac0d]102        :param x: input q, or [q,phi]
103        :return: scattering function P(q)
104        """
105        return [CPYTHONCLASS].run(self, x)
[c93122e]106
[fd5ac0d]107    def runXY(self, x=0.0):
[c93122e]108        """
[fd5ac0d]109        Evaluate the model in cartesian coordinates
[1f5f206]110
[fd5ac0d]111        :param x: input q, or [qx, qy]
112        :return: scattering function P(q)
113        """
114        return [CPYTHONCLASS].runXY(self, x)
[c93122e]115
[fd5ac0d]116    def evalDistribution(self, x):
[c93122e]117        """
[fd5ac0d]118        Evaluate the model in cartesian coordinates
[1f5f206]119
[fd5ac0d]120        :param x: input q[], or [qx[], qy[]]
121        :return: scattering function P(q[])
122        """
123        return [CPYTHONCLASS].evalDistribution(self, x)
[c93122e]124
[fd5ac0d]125    def calculate_ER(self):
[c93122e]126        """
[fd5ac0d]127        Calculate the effective radius for P(q)*S(q)
[1f5f206]128
[fd5ac0d]129        :return: the value of the effective radius
[c93122e]130        """
[fd5ac0d]131        return [CPYTHONCLASS].calculate_ER(self)
[c93122e]132
[fd5ac0d]133    def calculate_VR(self):
[c93122e]134        """
[fd5ac0d]135        Calculate the volf ratio for P(q)*S(q)
[1f5f206]136
[fd5ac0d]137        :return: the value of the volf ratio
[c93122e]138        """
[fd5ac0d]139        return [CPYTHONCLASS].calculate_VR(self)
[c93122e]140
[fd5ac0d]141    def set_dispersion(self, parameter, dispersion):
142        """
143        Set the dispersion object for a model parameter
[1f5f206]144
[fd5ac0d]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)
[c93122e]150
[fd5ac0d]151# End of file
Note: See TracBrowser for help on using the repository browser.