Changeset 9316609 in sasview for sansmodels/src/sans/models
- Timestamp:
- Oct 28, 2008 3:22:22 PM (16 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 92320e5
- Parents:
- 89fef2c
- Location:
- sansmodels/src/sans/models
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
sansmodels/src/sans/models/CoreShellCylinderModel.py
r96672c0 r9316609 42 42 ## Name of the model 43 43 self.name = "CoreShellCylinderModel" 44 44 self.description= """P(q,alpha)= scale/Vs*f(q)^(2) + bkg Where:\n\ 45 f(q)= 2(core_sld- solvant_sld)* Vc*sin[qLcos(alpha/2)]/\n\ 46 [qLcos(alpha/2)]*J1(qRsin(alpha))/[qRsin(alpha)] +\n 2(shell_sld-solvent_sld)*Vs 47 *sin[q(L+T)cos(alpha/2)]/[[q(L+T)cos(alpha/2)] 48 *J1(q(R+T)sin(alpha))/q(R+T)sin(alpha)] 49 alpha:is the angle between the axis of the cylinder and the q-vector 50 Vs: the volume of the outer shell 51 Vc: the volume of the core 52 L: the length of the core 53 shell_sld: the scattering length density of the shell 54 solvent_sld: the scattering length density of the solvent 55 bkg: the background 56 T: the thickness 57 R+T: is the outer radius 58 L+2T: The total length of the outershell 59 J1: the first order Bessel function 60 theta: axis_theta of the cylinder 61 phi: the axis_phi of the cylinder""" 45 62 ## Parameter details [units, min, max] 46 63 self.details = {} -
sansmodels/src/sans/models/CoreShellModel.py
r96672c0 r9316609 39 39 ## Name of the model 40 40 self.name = "CoreShellModel" 41 41 self.description= """""""" 42 42 ## Parameter details [units, min, max] 43 43 self.details = {} -
sansmodels/src/sans/models/CylinderModel.py
r96672c0 r9316609 3 3 4 4 WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 5 DO NOT MODIFY THIS FILE, MODIFY cylinder.h5 DO NOT MODIFY THIS FILE, MODIFY Cylinder.h 6 6 AND RE-RUN THE GENERATOR SCRIPT 7 7 … … 16 16 class CylinderModel(CCylinderModel, BaseComponent): 17 17 """ Class that evaluates a CylinderModel model. 18 This file was auto-generated from cylinder.h.18 This file was auto-generated from Cylinder.h. 19 19 Refer to that file and the structure it contains 20 20 for details of the model. … … 39 39 ## Name of the model 40 40 self.name = "CylinderModel" 41 41 self.description= """P(q,alpha)= scale/V*f(q)^(2)+bkg 42 f(q)= 2*(scatter_sld - solvent_sld)*V*sin(qLcos(alpha/2))/[qLcos(alpha/2)]* 43 J1(qRsin(alpha/2))/[qRsin(alpha)] 44 V: Volume of the cylinder 45 R: Radius of the cylinder 46 L: Length of the cylinder 47 J1: The bessel function 48 alpha: angle betweenthe axis of the cylinder and the q-vector 49 for 1D:the ouput is P(q)=scale/V*integral from pi/2 to zero of f(q)^(2)* 50 sin(alpha)*dalpha+ bkg""" 42 51 ## Parameter details [units, min, max] 43 52 self.details = {} -
sansmodels/src/sans/models/EllipsoidModel.py
r96672c0 r9316609 1 1 #!/usr/bin/env python 2 """3 This software was developed by the University of Tennessee as part of the4 Distributed Data Analysis of Neutron Scattering Experiments (DANSE)5 project funded by the US National Science Foundation.6 7 If you use DANSE applications to do scientific research that leads to8 publication, we ask that you acknowledge the use of the software with the9 following sentence:10 11 "This work benefited from DANSE software developed under NSF award DMR-0520547."12 13 copyright 2008, University of Tennessee14 """15 16 2 """ Provide functionality for a C extension model 17 3 18 4 WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 19 DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/ellipsoid.h5 DO NOT MODIFY THIS FILE, MODIFY ellipsoid.h 20 6 AND RE-RUN THE GENERATOR SCRIPT 21 7 8 @author: Mathieu Doucet / UTK 9 @contact: mathieu.doucet@nist.gov 22 10 """ 23 11 … … 28 16 class EllipsoidModel(CEllipsoidModel, BaseComponent): 29 17 """ Class that evaluates a EllipsoidModel model. 30 This file was auto-generated from ../c_extensions/ellipsoid.h.18 This file was auto-generated from ellipsoid.h. 31 19 Refer to that file and the structure it contains 32 20 for details of the model. … … 51 39 ## Name of the model 52 40 self.name = "EllipsoidModel" 53 41 self.description= """"P(q.alpha)= scale*f(q)^(2)+ bkg\n\ 42 f(q)= 3*(scatter_sld- scatter_solvent)*V*[sin(q*r(Ra,Rb,alpha)) - q*r*cos(qr(Ra,Rb,alpha))] 43 /[qr(Ra,Rb,alpha)]^(3)" 44 r(Ra,Rb,alpha)= [Rb^(2)*(sin(alpha))^(2) + Ra^(2)*(cos(alpha))^(2)]^(1/2) 45 scatter_sld: scattering length density of the scatter 46 solvent_sld: scattering length density of the solvent 47 V: volune of the Eliipsoid 48 Ra: radius along the rotation axis of the Ellipsoid 49 Rb: radius perpendicular to the rotation axis of the ellipsoid""" 54 50 ## Parameter details [units, min, max] 55 51 self.details = {} … … 65 61 def clone(self): 66 62 """ Return a identical copy of self """ 67 return self._clone(EllipsoidModel()) 63 obj = EllipsoidModel() 64 obj.params = copy.deepcopy(self.params) 65 return obj 68 66 69 67 def run(self, x = 0.0): … … 82 80 83 81 return CEllipsoidModel.runXY(self, x) 84 85 def set_dispersion(self, parameter, dispersion):86 """87 Set the dispersion object for a model parameter88 @param parameter: name of the parameter [string]89 @dispersion: dispersion object of type DispersionModel90 """91 return CEllipsoidModel.set_dispersion(self, parameter, dispersion.cdisp)92 93 82 94 83 # End of file -
sansmodels/src/sans/models/EllipticalCylinderModel.py
r8809e48 r9316609 1 1 #!/usr/bin/env python 2 """3 This software was developed by the University of Tennessee as part of the4 Distributed Data Analysis of Neutron Scattering Experiments (DANSE)5 project funded by the US National Science Foundation.6 7 If you use DANSE applications to do scientific research that leads to8 publication, we ask that you acknowledge the use of the software with the9 following sentence:10 11 "This work benefited from DANSE software developed under NSF award DMR-0520547."12 13 copyright 2008, University of Tennessee14 """15 16 2 """ Provide functionality for a C extension model 17 3 18 4 WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 19 DO NOT MODIFY THIS FILE, MODIFY ../c_extensions/elliptical_cylinder.h5 DO NOT MODIFY THIS FILE, MODIFY elliptical_cylinder.h 20 6 AND RE-RUN THE GENERATOR SCRIPT 21 7 8 @author: Mathieu Doucet / UTK 9 @contact: mathieu.doucet@nist.gov 22 10 """ 23 11 … … 28 16 class EllipticalCylinderModel(CEllipticalCylinderModel, BaseComponent): 29 17 """ Class that evaluates a EllipticalCylinderModel model. 30 This file was auto-generated from ../c_extensions/elliptical_cylinder.h.18 This file was auto-generated from elliptical_cylinder.h. 31 19 Refer to that file and the structure it contains 32 20 for details of the model. … … 53 41 ## Name of the model 54 42 self.name = "EllipticalCylinderModel" 55 43 self.description= """""""" 56 44 ## Parameter details [units, min, max] 57 45 self.details = {} … … 69 57 def clone(self): 70 58 """ Return a identical copy of self """ 71 return self._clone(EllipticalCylinderModel()) 59 obj = EllipticalCylinderModel() 60 obj.params = copy.deepcopy(self.params) 61 return obj 72 62 73 63 def run(self, x = 0.0): … … 86 76 87 77 return CEllipticalCylinderModel.runXY(self, x) 88 89 def set_dispersion(self, parameter, dispersion):90 """91 Set the dispersion object for a model parameter92 @param parameter: name of the parameter [string]93 @dispersion: dispersion object of type DispersionModel94 """95 return CEllipticalCylinderModel.set_dispersion(self, parameter, dispersion.cdisp)96 97 78 98 79 # End of file -
sansmodels/src/sans/models/Gaussian.py
r96672c0 r9316609 35 35 ## Name of the model 36 36 self.name = "Gaussian" 37 37 self.description= """f(x)=scale * 1/(sigma^2*2pi)e^(-(x-mu)^2/2sigma^2)""" 38 38 ## Parameter details [units, min, max] 39 39 self.details = {} -
sansmodels/src/sans/models/Lorentzian.py
r5f89fb8 r9316609 35 35 ## Name of the model 36 36 self.name = "Lorentzian" 37 self.description= ''37 self.description= """f(x)=scale * 1/pi 0.5gamma / [ (x-x_0)^2 + (0.5gamma)^2 ]""" 38 38 ## Parameter details [units, min, max] 39 39 self.details = {} -
sansmodels/src/sans/models/SphereModel.py
r96672c0 r9316609 36 36 ## Name of the model 37 37 self.name = "SphereModel" 38 38 self.description= """P(q)=(scale/V)*[3V(scatter_sld-solvent_sld)*(sin(qR)-qRcos(qR))/(qR)^3]^(2) 39 +bkg 40 bkg: background level 41 R: radius of the sphere 42 V:The volume of the scatter 43 scatter_sld: the scattering length density of the scatter 44 solvent_sld: the scattering length density of the solvent""" 39 45 ## Parameter details [units, min, max] 40 46 self.details = {} -
sansmodels/src/sans/models/c_extensions/CCoreShellCylinderModel.c
rae3ce4e r9316609 1 /** CCoreShellCylinderModel1 /** [PYTHONCLASS] 2 2 * 3 3 * C extension … … 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * CCoreShellCylinderModelError = NULL;22 static PyObject * [PYTHONCLASS]Error = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 CoreShellCylinderParameters model_pars; 34 } CCoreShellCylinderModel;34 } [PYTHONCLASS]; 35 35 36 36 37 37 static void 38 CCoreShellCylinderModel_dealloc(CCoreShellCylinderModel* self)38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 CCoreShellCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 CCoreShellCylinderModel*self;48 [PYTHONCLASS] *self; 49 49 50 self = ( CCoreShellCylinderModel*)type->tp_alloc(type, 0);50 self = ([PYTHONCLASS] *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 CCoreShellCylinderModel_init(CCoreShellCylinderModel*self, PyObject *args, PyObject *kwds)56 [PYTHONCLASS]_init([PYTHONCLASS] *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 83 83 } 84 84 85 static PyMemberDef CCoreShellCylinderModel_members[] = {86 {"params", T_OBJECT, offsetof( CCoreShellCylinderModel, params), 0,85 static PyMemberDef [PYTHONCLASS]_members[] = { 86 {"params", T_OBJECT, offsetof([PYTHONCLASS], params), 0, 87 87 "Parameters"}, 88 {"log", T_OBJECT, offsetof( CCoreShellCylinderModel, log), 0,88 {"log", T_OBJECT, offsetof([PYTHONCLASS], log), 0, 89 89 "Log"}, 90 90 {NULL} /* Sentinel */ … … 95 95 @return double 96 96 */ 97 double CCoreShellCylinderModel_readDouble(PyObject *p) {97 double [PYTHONCLASS]_readDouble(PyObject *p) { 98 98 if (PyFloat_Check(p)==1) { 99 99 return (double)(((PyFloatObject *)(p))->ob_fval); … … 113 113 * @return: function value 114 114 */ 115 static PyObject * run( CCoreShellCylinderModel*self, PyObject *args) {115 static PyObject * run([PYTHONCLASS] *self, PyObject *args) { 116 116 double q_value, phi_value; 117 117 PyObject* pars; … … 135 135 // Get input and determine whether we have to supply a 1D or 2D return value. 136 136 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 137 PyErr_SetString( CCoreShellCylinderModelError,138 " CCoreShellCylinderModel.run expects a q value.");137 PyErr_SetString([PYTHONCLASS]Error, 138 "[PYTHONCLASS].run expects a q value."); 139 139 return NULL; 140 140 } … … 146 146 npars = PyList_GET_SIZE(pars); 147 147 if(npars!=2) { 148 PyErr_SetString( CCoreShellCylinderModelError,149 " CCoreShellCylinderModel.run expects a double or a list of dimension 2.");148 PyErr_SetString([PYTHONCLASS]Error, 149 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 150 150 return NULL; 151 151 } 152 152 // We have a vector q, get the q and phi values at which 153 153 // to evaluate I(q,phi) 154 q_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,0));155 phi_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,1));154 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 155 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 156 156 // Skip zero 157 157 if (q_value==0) { … … 163 163 164 164 // We have a scalar q, we will evaluate I(q) 165 q_value = CCoreShellCylinderModel_readDouble(pars);165 q_value = [PYTHONCLASS]_readDouble(pars); 166 166 167 167 return Py_BuildValue("d",core_shell_cylinder_analytical_1D(&(self->model_pars),q_value)); … … 174 174 * @return: function value 175 175 */ 176 static PyObject * runXY( CCoreShellCylinderModel*self, PyObject *args) {176 static PyObject * runXY([PYTHONCLASS] *self, PyObject *args) { 177 177 double qx_value, qy_value; 178 178 PyObject* pars; … … 196 196 // Get input and determine whether we have to supply a 1D or 2D return value. 197 197 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 198 PyErr_SetString( CCoreShellCylinderModelError,199 " CCoreShellCylinderModel.run expects a q value.");198 PyErr_SetString([PYTHONCLASS]Error, 199 "[PYTHONCLASS].run expects a q value."); 200 200 return NULL; 201 201 } … … 207 207 npars = PyList_GET_SIZE(pars); 208 208 if(npars!=2) { 209 PyErr_SetString( CCoreShellCylinderModelError,210 " CCoreShellCylinderModel.run expects a double or a list of dimension 2.");209 PyErr_SetString([PYTHONCLASS]Error, 210 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 211 211 return NULL; 212 212 } 213 213 // We have a vector q, get the qx and qy values at which 214 214 // to evaluate I(qx,qy) 215 qx_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,0));216 qy_value = CCoreShellCylinderModel_readDouble(PyList_GET_ITEM(pars,1));215 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 216 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 217 217 return Py_BuildValue("d",core_shell_cylinder_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 218 218 … … 220 220 221 221 // We have a scalar q, we will evaluate I(q) 222 qx_value = CCoreShellCylinderModel_readDouble(pars);222 qx_value = [PYTHONCLASS]_readDouble(pars); 223 223 224 224 return Py_BuildValue("d",core_shell_cylinder_analytical_1D(&(self->model_pars),qx_value)); … … 226 226 } 227 227 228 static PyObject * reset( CCoreShellCylinderModel*self, PyObject *args) {228 static PyObject * reset([PYTHONCLASS] *self, PyObject *args) { 229 229 230 230 … … 233 233 234 234 235 static PyMethodDef CCoreShellCylinderModel_methods[] = {235 static PyMethodDef [PYTHONCLASS]_methods[] = { 236 236 {"run", (PyCFunction)run , METH_VARARGS, 237 237 "Evaluate the model at a given Q or Q, phi"}, … … 245 245 }; 246 246 247 static PyTypeObject CCoreShellCylinderModelType = {247 static PyTypeObject [PYTHONCLASS]Type = { 248 248 PyObject_HEAD_INIT(NULL) 249 249 0, /*ob_size*/ 250 " CCoreShellCylinderModel", /*tp_name*/251 sizeof( CCoreShellCylinderModel), /*tp_basicsize*/250 "[PYTHONCLASS]", /*tp_name*/ 251 sizeof([PYTHONCLASS]), /*tp_basicsize*/ 252 252 0, /*tp_itemsize*/ 253 (destructor) CCoreShellCylinderModel_dealloc, /*tp_dealloc*/253 (destructor)[PYTHONCLASS]_dealloc, /*tp_dealloc*/ 254 254 0, /*tp_print*/ 255 255 0, /*tp_getattr*/ … … 267 267 0, /*tp_as_buffer*/ 268 268 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 269 " CCoreShellCylinderModelobjects", /* tp_doc */269 "[PYTHONCLASS] objects", /* tp_doc */ 270 270 0, /* tp_traverse */ 271 271 0, /* tp_clear */ … … 274 274 0, /* tp_iter */ 275 275 0, /* tp_iternext */ 276 CCoreShellCylinderModel_methods, /* tp_methods */277 CCoreShellCylinderModel_members, /* tp_members */276 [PYTHONCLASS]_methods, /* tp_methods */ 277 [PYTHONCLASS]_members, /* tp_members */ 278 278 0, /* tp_getset */ 279 279 0, /* tp_base */ … … 282 282 0, /* tp_descr_set */ 283 283 0, /* tp_dictoffset */ 284 (initproc) CCoreShellCylinderModel_init, /* tp_init */284 (initproc)[PYTHONCLASS]_init, /* tp_init */ 285 285 0, /* tp_alloc */ 286 CCoreShellCylinderModel_new, /* tp_new */286 [PYTHONCLASS]_new, /* tp_new */ 287 287 }; 288 288 … … 296 296 * @param module: module to add the class to 297 297 */ 298 void add CCoreShellCylinderModel(PyObject *module) {298 void add[PYTHONCLASS](PyObject *module) { 299 299 PyObject *d; 300 300 301 if (PyType_Ready(& CCoreShellCylinderModelType) < 0)301 if (PyType_Ready(&[PYTHONCLASS]Type) < 0) 302 302 return; 303 303 304 Py_INCREF(& CCoreShellCylinderModelType);305 PyModule_AddObject(module, " CCoreShellCylinderModel", (PyObject *)&CCoreShellCylinderModelType);304 Py_INCREF(&[PYTHONCLASS]Type); 305 PyModule_AddObject(module, "[PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type); 306 306 307 307 d = PyModule_GetDict(module); 308 CCoreShellCylinderModelError = PyErr_NewException("CCoreShellCylinderModel.error", NULL, NULL);309 PyDict_SetItemString(d, " CCoreShellCylinderModelError", CCoreShellCylinderModelError);310 } 311 308 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL); 309 PyDict_SetItemString(d, "[PYTHONCLASS]Error", [PYTHONCLASS]Error); 310 } 311 -
sansmodels/src/sans/models/c_extensions/CCoreShellModel.c
rae3ce4e r9316609 1 /** CCoreShellModel1 /** [PYTHONCLASS] 2 2 * 3 3 * C extension … … 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * CCoreShellModelError = NULL;22 static PyObject * [PYTHONCLASS]Error = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 CoreShellParameters model_pars; 34 } CCoreShellModel;34 } [PYTHONCLASS]; 35 35 36 36 37 37 static void 38 CCoreShellModel_dealloc(CCoreShellModel* self)38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 CCoreShellModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 CCoreShellModel*self;48 [PYTHONCLASS] *self; 49 49 50 self = ( CCoreShellModel*)type->tp_alloc(type, 0);50 self = ([PYTHONCLASS] *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 CCoreShellModel_init(CCoreShellModel*self, PyObject *args, PyObject *kwds)56 [PYTHONCLASS]_init([PYTHONCLASS] *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 80 80 } 81 81 82 static PyMemberDef CCoreShellModel_members[] = {83 {"params", T_OBJECT, offsetof( CCoreShellModel, params), 0,82 static PyMemberDef [PYTHONCLASS]_members[] = { 83 {"params", T_OBJECT, offsetof([PYTHONCLASS], params), 0, 84 84 "Parameters"}, 85 {"log", T_OBJECT, offsetof( CCoreShellModel, log), 0,85 {"log", T_OBJECT, offsetof([PYTHONCLASS], log), 0, 86 86 "Log"}, 87 87 {NULL} /* Sentinel */ … … 92 92 @return double 93 93 */ 94 double CCoreShellModel_readDouble(PyObject *p) {94 double [PYTHONCLASS]_readDouble(PyObject *p) { 95 95 if (PyFloat_Check(p)==1) { 96 96 return (double)(((PyFloatObject *)(p))->ob_fval); … … 110 110 * @return: function value 111 111 */ 112 static PyObject * run( CCoreShellModel*self, PyObject *args) {112 static PyObject * run([PYTHONCLASS] *self, PyObject *args) { 113 113 double q_value, phi_value; 114 114 PyObject* pars; … … 129 129 // Get input and determine whether we have to supply a 1D or 2D return value. 130 130 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 131 PyErr_SetString( CCoreShellModelError,132 " CCoreShellModel.run expects a q value.");131 PyErr_SetString([PYTHONCLASS]Error, 132 "[PYTHONCLASS].run expects a q value."); 133 133 return NULL; 134 134 } … … 140 140 npars = PyList_GET_SIZE(pars); 141 141 if(npars!=2) { 142 PyErr_SetString( CCoreShellModelError,143 " CCoreShellModel.run expects a double or a list of dimension 2.");142 PyErr_SetString([PYTHONCLASS]Error, 143 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 144 144 return NULL; 145 145 } 146 146 // We have a vector q, get the q and phi values at which 147 147 // to evaluate I(q,phi) 148 q_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,0));149 phi_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,1));148 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 149 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 150 150 // Skip zero 151 151 if (q_value==0) { … … 157 157 158 158 // We have a scalar q, we will evaluate I(q) 159 q_value = CCoreShellModel_readDouble(pars);159 q_value = [PYTHONCLASS]_readDouble(pars); 160 160 161 161 return Py_BuildValue("d",core_shell_analytical_1D(&(self->model_pars),q_value)); … … 168 168 * @return: function value 169 169 */ 170 static PyObject * runXY( CCoreShellModel*self, PyObject *args) {170 static PyObject * runXY([PYTHONCLASS] *self, PyObject *args) { 171 171 double qx_value, qy_value; 172 172 PyObject* pars; … … 187 187 // Get input and determine whether we have to supply a 1D or 2D return value. 188 188 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 189 PyErr_SetString( CCoreShellModelError,190 " CCoreShellModel.run expects a q value.");189 PyErr_SetString([PYTHONCLASS]Error, 190 "[PYTHONCLASS].run expects a q value."); 191 191 return NULL; 192 192 } … … 198 198 npars = PyList_GET_SIZE(pars); 199 199 if(npars!=2) { 200 PyErr_SetString( CCoreShellModelError,201 " CCoreShellModel.run expects a double or a list of dimension 2.");200 PyErr_SetString([PYTHONCLASS]Error, 201 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 202 202 return NULL; 203 203 } 204 204 // We have a vector q, get the qx and qy values at which 205 205 // to evaluate I(qx,qy) 206 qx_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,0));207 qy_value = CCoreShellModel_readDouble(PyList_GET_ITEM(pars,1));206 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 207 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 208 208 return Py_BuildValue("d",core_shell_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 209 209 … … 211 211 212 212 // We have a scalar q, we will evaluate I(q) 213 qx_value = CCoreShellModel_readDouble(pars);213 qx_value = [PYTHONCLASS]_readDouble(pars); 214 214 215 215 return Py_BuildValue("d",core_shell_analytical_1D(&(self->model_pars),qx_value)); … … 217 217 } 218 218 219 static PyObject * reset( CCoreShellModel*self, PyObject *args) {219 static PyObject * reset([PYTHONCLASS] *self, PyObject *args) { 220 220 221 221 … … 224 224 225 225 226 static PyMethodDef CCoreShellModel_methods[] = {226 static PyMethodDef [PYTHONCLASS]_methods[] = { 227 227 {"run", (PyCFunction)run , METH_VARARGS, 228 228 "Evaluate the model at a given Q or Q, phi"}, … … 236 236 }; 237 237 238 static PyTypeObject CCoreShellModelType = {238 static PyTypeObject [PYTHONCLASS]Type = { 239 239 PyObject_HEAD_INIT(NULL) 240 240 0, /*ob_size*/ 241 " CCoreShellModel", /*tp_name*/242 sizeof( CCoreShellModel), /*tp_basicsize*/241 "[PYTHONCLASS]", /*tp_name*/ 242 sizeof([PYTHONCLASS]), /*tp_basicsize*/ 243 243 0, /*tp_itemsize*/ 244 (destructor) CCoreShellModel_dealloc, /*tp_dealloc*/244 (destructor)[PYTHONCLASS]_dealloc, /*tp_dealloc*/ 245 245 0, /*tp_print*/ 246 246 0, /*tp_getattr*/ … … 258 258 0, /*tp_as_buffer*/ 259 259 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 260 " CCoreShellModelobjects", /* tp_doc */260 "[PYTHONCLASS] objects", /* tp_doc */ 261 261 0, /* tp_traverse */ 262 262 0, /* tp_clear */ … … 265 265 0, /* tp_iter */ 266 266 0, /* tp_iternext */ 267 CCoreShellModel_methods, /* tp_methods */268 CCoreShellModel_members, /* tp_members */267 [PYTHONCLASS]_methods, /* tp_methods */ 268 [PYTHONCLASS]_members, /* tp_members */ 269 269 0, /* tp_getset */ 270 270 0, /* tp_base */ … … 273 273 0, /* tp_descr_set */ 274 274 0, /* tp_dictoffset */ 275 (initproc) CCoreShellModel_init, /* tp_init */275 (initproc)[PYTHONCLASS]_init, /* tp_init */ 276 276 0, /* tp_alloc */ 277 CCoreShellModel_new, /* tp_new */277 [PYTHONCLASS]_new, /* tp_new */ 278 278 }; 279 279 … … 287 287 * @param module: module to add the class to 288 288 */ 289 void add CCoreShellModel(PyObject *module) {289 void add[PYTHONCLASS](PyObject *module) { 290 290 PyObject *d; 291 291 292 if (PyType_Ready(& CCoreShellModelType) < 0)292 if (PyType_Ready(&[PYTHONCLASS]Type) < 0) 293 293 return; 294 294 295 Py_INCREF(& CCoreShellModelType);296 PyModule_AddObject(module, " CCoreShellModel", (PyObject *)&CCoreShellModelType);295 Py_INCREF(&[PYTHONCLASS]Type); 296 PyModule_AddObject(module, "[PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type); 297 297 298 298 d = PyModule_GetDict(module); 299 CCoreShellModelError = PyErr_NewException("CCoreShellModel.error", NULL, NULL);300 PyDict_SetItemString(d, " CCoreShellModelError", CCoreShellModelError);301 } 302 299 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL); 300 PyDict_SetItemString(d, "[PYTHONCLASS]Error", [PYTHONCLASS]Error); 301 } 302 -
sansmodels/src/sans/models/c_extensions/CCylinderModel.c
rae3ce4e r9316609 1 /** CCylinderModel1 /** [PYTHONCLASS] 2 2 * 3 3 * C extension 4 4 * 5 5 * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 6 * DO NOT MODIFY THIS FILE, MODIFY cylinder.h6 * DO NOT MODIFY THIS FILE, MODIFY Cylinder.h 7 7 * AND RE-RUN THE GENERATOR SCRIPT 8 8 * … … 17 17 #include <time.h> 18 18 19 #include " cylinder.h"19 #include "Cylinder.h" 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * CCylinderModelError = NULL;22 static PyObject * [PYTHONCLASS]Error = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 CylinderParameters model_pars; 34 } CCylinderModel;34 } [PYTHONCLASS]; 35 35 36 36 37 37 static void 38 CCylinderModel_dealloc(CCylinderModel* self)38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 CCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 CCylinderModel*self;48 [PYTHONCLASS] *self; 49 49 50 self = ( CCylinderModel*)type->tp_alloc(type, 0);50 self = ([PYTHONCLASS] *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 CCylinderModel_init(CCylinderModel*self, PyObject *args, PyObject *kwds)56 [PYTHONCLASS]_init([PYTHONCLASS] *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 80 80 } 81 81 82 static PyMemberDef CCylinderModel_members[] = {83 {"params", T_OBJECT, offsetof( CCylinderModel, params), 0,82 static PyMemberDef [PYTHONCLASS]_members[] = { 83 {"params", T_OBJECT, offsetof([PYTHONCLASS], params), 0, 84 84 "Parameters"}, 85 {"log", T_OBJECT, offsetof( CCylinderModel, log), 0,85 {"log", T_OBJECT, offsetof([PYTHONCLASS], log), 0, 86 86 "Log"}, 87 87 {NULL} /* Sentinel */ … … 92 92 @return double 93 93 */ 94 double CCylinderModel_readDouble(PyObject *p) {94 double [PYTHONCLASS]_readDouble(PyObject *p) { 95 95 if (PyFloat_Check(p)==1) { 96 96 return (double)(((PyFloatObject *)(p))->ob_fval); … … 110 110 * @return: function value 111 111 */ 112 static PyObject * run( CCylinderModel*self, PyObject *args) {112 static PyObject * run([PYTHONCLASS] *self, PyObject *args) { 113 113 double q_value, phi_value; 114 114 PyObject* pars; … … 129 129 // Get input and determine whether we have to supply a 1D or 2D return value. 130 130 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 131 PyErr_SetString( CCylinderModelError,132 " CCylinderModel.run expects a q value.");131 PyErr_SetString([PYTHONCLASS]Error, 132 "[PYTHONCLASS].run expects a q value."); 133 133 return NULL; 134 134 } … … 140 140 npars = PyList_GET_SIZE(pars); 141 141 if(npars!=2) { 142 PyErr_SetString( CCylinderModelError,143 " CCylinderModel.run expects a double or a list of dimension 2.");142 PyErr_SetString([PYTHONCLASS]Error, 143 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 144 144 return NULL; 145 145 } 146 146 // We have a vector q, get the q and phi values at which 147 147 // to evaluate I(q,phi) 148 q_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0));149 phi_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,1));148 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 149 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 150 150 // Skip zero 151 151 if (q_value==0) { 152 152 return Py_BuildValue("d",0.0); 153 153 } 154 return Py_BuildValue("d", cylinder_analytical_2D(&(self->model_pars),q_value,phi_value));154 return Py_BuildValue("d",Cylinder_analytical_2D(&(self->model_pars),q_value,phi_value)); 155 155 156 156 } else { 157 157 158 158 // We have a scalar q, we will evaluate I(q) 159 q_value = CCylinderModel_readDouble(pars);159 q_value = [PYTHONCLASS]_readDouble(pars); 160 160 161 return Py_BuildValue("d", cylinder_analytical_1D(&(self->model_pars),q_value));161 return Py_BuildValue("d",Cylinder_analytical_1D(&(self->model_pars),q_value)); 162 162 } 163 163 } … … 168 168 * @return: function value 169 169 */ 170 static PyObject * runXY( CCylinderModel*self, PyObject *args) {170 static PyObject * runXY([PYTHONCLASS] *self, PyObject *args) { 171 171 double qx_value, qy_value; 172 172 PyObject* pars; … … 187 187 // Get input and determine whether we have to supply a 1D or 2D return value. 188 188 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 189 PyErr_SetString( CCylinderModelError,190 " CCylinderModel.run expects a q value.");189 PyErr_SetString([PYTHONCLASS]Error, 190 "[PYTHONCLASS].run expects a q value."); 191 191 return NULL; 192 192 } … … 198 198 npars = PyList_GET_SIZE(pars); 199 199 if(npars!=2) { 200 PyErr_SetString( CCylinderModelError,201 " CCylinderModel.run expects a double or a list of dimension 2.");200 PyErr_SetString([PYTHONCLASS]Error, 201 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 202 202 return NULL; 203 203 } 204 204 // We have a vector q, get the qx and qy values at which 205 205 // to evaluate I(qx,qy) 206 qx_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,0));207 qy_value = CCylinderModel_readDouble(PyList_GET_ITEM(pars,1));208 return Py_BuildValue("d", cylinder_analytical_2DXY(&(self->model_pars),qx_value,qy_value));206 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 207 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 208 return Py_BuildValue("d",Cylinder_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 209 209 210 210 } else { 211 211 212 212 // We have a scalar q, we will evaluate I(q) 213 qx_value = CCylinderModel_readDouble(pars);213 qx_value = [PYTHONCLASS]_readDouble(pars); 214 214 215 return Py_BuildValue("d", cylinder_analytical_1D(&(self->model_pars),qx_value));215 return Py_BuildValue("d",Cylinder_analytical_1D(&(self->model_pars),qx_value)); 216 216 } 217 217 } 218 218 219 static PyObject * reset( CCylinderModel*self, PyObject *args) {219 static PyObject * reset([PYTHONCLASS] *self, PyObject *args) { 220 220 221 221 … … 224 224 225 225 226 static PyMethodDef CCylinderModel_methods[] = {226 static PyMethodDef [PYTHONCLASS]_methods[] = { 227 227 {"run", (PyCFunction)run , METH_VARARGS, 228 228 "Evaluate the model at a given Q or Q, phi"}, … … 236 236 }; 237 237 238 static PyTypeObject CCylinderModelType = {238 static PyTypeObject [PYTHONCLASS]Type = { 239 239 PyObject_HEAD_INIT(NULL) 240 240 0, /*ob_size*/ 241 " CCylinderModel", /*tp_name*/242 sizeof( CCylinderModel), /*tp_basicsize*/241 "[PYTHONCLASS]", /*tp_name*/ 242 sizeof([PYTHONCLASS]), /*tp_basicsize*/ 243 243 0, /*tp_itemsize*/ 244 (destructor) CCylinderModel_dealloc, /*tp_dealloc*/244 (destructor)[PYTHONCLASS]_dealloc, /*tp_dealloc*/ 245 245 0, /*tp_print*/ 246 246 0, /*tp_getattr*/ … … 258 258 0, /*tp_as_buffer*/ 259 259 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 260 " CCylinderModelobjects", /* tp_doc */260 "[PYTHONCLASS] objects", /* tp_doc */ 261 261 0, /* tp_traverse */ 262 262 0, /* tp_clear */ … … 265 265 0, /* tp_iter */ 266 266 0, /* tp_iternext */ 267 CCylinderModel_methods, /* tp_methods */268 CCylinderModel_members, /* tp_members */267 [PYTHONCLASS]_methods, /* tp_methods */ 268 [PYTHONCLASS]_members, /* tp_members */ 269 269 0, /* tp_getset */ 270 270 0, /* tp_base */ … … 273 273 0, /* tp_descr_set */ 274 274 0, /* tp_dictoffset */ 275 (initproc) CCylinderModel_init, /* tp_init */275 (initproc)[PYTHONCLASS]_init, /* tp_init */ 276 276 0, /* tp_alloc */ 277 CCylinderModel_new, /* tp_new */277 [PYTHONCLASS]_new, /* tp_new */ 278 278 }; 279 279 … … 287 287 * @param module: module to add the class to 288 288 */ 289 void add CCylinderModel(PyObject *module) {289 void add[PYTHONCLASS](PyObject *module) { 290 290 PyObject *d; 291 291 292 if (PyType_Ready(& CCylinderModelType) < 0)292 if (PyType_Ready(&[PYTHONCLASS]Type) < 0) 293 293 return; 294 294 295 Py_INCREF(& CCylinderModelType);296 PyModule_AddObject(module, " CCylinderModel", (PyObject *)&CCylinderModelType);295 Py_INCREF(&[PYTHONCLASS]Type); 296 PyModule_AddObject(module, "[PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type); 297 297 298 298 d = PyModule_GetDict(module); 299 CCylinderModelError = PyErr_NewException("CCylinderModel.error", NULL, NULL);300 PyDict_SetItemString(d, " CCylinderModelError", CCylinderModelError);301 } 302 299 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL); 300 PyDict_SetItemString(d, "[PYTHONCLASS]Error", [PYTHONCLASS]Error); 301 } 302 -
sansmodels/src/sans/models/c_extensions/CEllipsoidModel.c
rae3ce4e r9316609 1 /** CEllipsoidModel1 /** [PYTHONCLASS] 2 2 * 3 3 * C extension … … 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * CEllipsoidModelError = NULL;22 static PyObject * [PYTHONCLASS]Error = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 EllipsoidParameters model_pars; 34 } CEllipsoidModel;34 } [PYTHONCLASS]; 35 35 36 36 37 37 static void 38 CEllipsoidModel_dealloc(CEllipsoidModel* self)38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 CEllipsoidModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 CEllipsoidModel*self;48 [PYTHONCLASS] *self; 49 49 50 self = ( CEllipsoidModel*)type->tp_alloc(type, 0);50 self = ([PYTHONCLASS] *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 CEllipsoidModel_init(CEllipsoidModel*self, PyObject *args, PyObject *kwds)56 [PYTHONCLASS]_init([PYTHONCLASS] *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 80 80 } 81 81 82 static PyMemberDef CEllipsoidModel_members[] = {83 {"params", T_OBJECT, offsetof( CEllipsoidModel, params), 0,82 static PyMemberDef [PYTHONCLASS]_members[] = { 83 {"params", T_OBJECT, offsetof([PYTHONCLASS], params), 0, 84 84 "Parameters"}, 85 {"log", T_OBJECT, offsetof( CEllipsoidModel, log), 0,85 {"log", T_OBJECT, offsetof([PYTHONCLASS], log), 0, 86 86 "Log"}, 87 87 {NULL} /* Sentinel */ … … 92 92 @return double 93 93 */ 94 double CEllipsoidModel_readDouble(PyObject *p) {94 double [PYTHONCLASS]_readDouble(PyObject *p) { 95 95 if (PyFloat_Check(p)==1) { 96 96 return (double)(((PyFloatObject *)(p))->ob_fval); … … 110 110 * @return: function value 111 111 */ 112 static PyObject * run( CEllipsoidModel*self, PyObject *args) {112 static PyObject * run([PYTHONCLASS] *self, PyObject *args) { 113 113 double q_value, phi_value; 114 114 PyObject* pars; … … 129 129 // Get input and determine whether we have to supply a 1D or 2D return value. 130 130 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 131 PyErr_SetString( CEllipsoidModelError,132 " CEllipsoidModel.run expects a q value.");131 PyErr_SetString([PYTHONCLASS]Error, 132 "[PYTHONCLASS].run expects a q value."); 133 133 return NULL; 134 134 } … … 140 140 npars = PyList_GET_SIZE(pars); 141 141 if(npars!=2) { 142 PyErr_SetString( CEllipsoidModelError,143 " CEllipsoidModel.run expects a double or a list of dimension 2.");142 PyErr_SetString([PYTHONCLASS]Error, 143 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 144 144 return NULL; 145 145 } 146 146 // We have a vector q, get the q and phi values at which 147 147 // to evaluate I(q,phi) 148 q_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,0));149 phi_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,1));148 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 149 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 150 150 // Skip zero 151 151 if (q_value==0) { … … 157 157 158 158 // We have a scalar q, we will evaluate I(q) 159 q_value = CEllipsoidModel_readDouble(pars);159 q_value = [PYTHONCLASS]_readDouble(pars); 160 160 161 161 return Py_BuildValue("d",ellipsoid_analytical_1D(&(self->model_pars),q_value)); … … 168 168 * @return: function value 169 169 */ 170 static PyObject * runXY( CEllipsoidModel*self, PyObject *args) {170 static PyObject * runXY([PYTHONCLASS] *self, PyObject *args) { 171 171 double qx_value, qy_value; 172 172 PyObject* pars; … … 187 187 // Get input and determine whether we have to supply a 1D or 2D return value. 188 188 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 189 PyErr_SetString( CEllipsoidModelError,190 " CEllipsoidModel.run expects a q value.");189 PyErr_SetString([PYTHONCLASS]Error, 190 "[PYTHONCLASS].run expects a q value."); 191 191 return NULL; 192 192 } … … 198 198 npars = PyList_GET_SIZE(pars); 199 199 if(npars!=2) { 200 PyErr_SetString( CEllipsoidModelError,201 " CEllipsoidModel.run expects a double or a list of dimension 2.");200 PyErr_SetString([PYTHONCLASS]Error, 201 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 202 202 return NULL; 203 203 } 204 204 // We have a vector q, get the qx and qy values at which 205 205 // to evaluate I(qx,qy) 206 qx_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,0));207 qy_value = CEllipsoidModel_readDouble(PyList_GET_ITEM(pars,1));206 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 207 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 208 208 return Py_BuildValue("d",ellipsoid_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 209 209 … … 211 211 212 212 // We have a scalar q, we will evaluate I(q) 213 qx_value = CEllipsoidModel_readDouble(pars);213 qx_value = [PYTHONCLASS]_readDouble(pars); 214 214 215 215 return Py_BuildValue("d",ellipsoid_analytical_1D(&(self->model_pars),qx_value)); … … 217 217 } 218 218 219 static PyObject * reset( CEllipsoidModel*self, PyObject *args) {219 static PyObject * reset([PYTHONCLASS] *self, PyObject *args) { 220 220 221 221 … … 224 224 225 225 226 static PyMethodDef CEllipsoidModel_methods[] = {226 static PyMethodDef [PYTHONCLASS]_methods[] = { 227 227 {"run", (PyCFunction)run , METH_VARARGS, 228 228 "Evaluate the model at a given Q or Q, phi"}, … … 236 236 }; 237 237 238 static PyTypeObject CEllipsoidModelType = {238 static PyTypeObject [PYTHONCLASS]Type = { 239 239 PyObject_HEAD_INIT(NULL) 240 240 0, /*ob_size*/ 241 " CEllipsoidModel", /*tp_name*/242 sizeof( CEllipsoidModel), /*tp_basicsize*/241 "[PYTHONCLASS]", /*tp_name*/ 242 sizeof([PYTHONCLASS]), /*tp_basicsize*/ 243 243 0, /*tp_itemsize*/ 244 (destructor) CEllipsoidModel_dealloc, /*tp_dealloc*/244 (destructor)[PYTHONCLASS]_dealloc, /*tp_dealloc*/ 245 245 0, /*tp_print*/ 246 246 0, /*tp_getattr*/ … … 258 258 0, /*tp_as_buffer*/ 259 259 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 260 " CEllipsoidModelobjects", /* tp_doc */260 "[PYTHONCLASS] objects", /* tp_doc */ 261 261 0, /* tp_traverse */ 262 262 0, /* tp_clear */ … … 265 265 0, /* tp_iter */ 266 266 0, /* tp_iternext */ 267 CEllipsoidModel_methods, /* tp_methods */268 CEllipsoidModel_members, /* tp_members */267 [PYTHONCLASS]_methods, /* tp_methods */ 268 [PYTHONCLASS]_members, /* tp_members */ 269 269 0, /* tp_getset */ 270 270 0, /* tp_base */ … … 273 273 0, /* tp_descr_set */ 274 274 0, /* tp_dictoffset */ 275 (initproc) CEllipsoidModel_init, /* tp_init */275 (initproc)[PYTHONCLASS]_init, /* tp_init */ 276 276 0, /* tp_alloc */ 277 CEllipsoidModel_new, /* tp_new */277 [PYTHONCLASS]_new, /* tp_new */ 278 278 }; 279 279 … … 287 287 * @param module: module to add the class to 288 288 */ 289 void add CEllipsoidModel(PyObject *module) {289 void add[PYTHONCLASS](PyObject *module) { 290 290 PyObject *d; 291 291 292 if (PyType_Ready(& CEllipsoidModelType) < 0)292 if (PyType_Ready(&[PYTHONCLASS]Type) < 0) 293 293 return; 294 294 295 Py_INCREF(& CEllipsoidModelType);296 PyModule_AddObject(module, " CEllipsoidModel", (PyObject *)&CEllipsoidModelType);295 Py_INCREF(&[PYTHONCLASS]Type); 296 PyModule_AddObject(module, "[PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type); 297 297 298 298 d = PyModule_GetDict(module); 299 CEllipsoidModelError = PyErr_NewException("CEllipsoidModel.error", NULL, NULL);300 PyDict_SetItemString(d, " CEllipsoidModelError", CEllipsoidModelError);301 } 302 299 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL); 300 PyDict_SetItemString(d, "[PYTHONCLASS]Error", [PYTHONCLASS]Error); 301 } 302 -
sansmodels/src/sans/models/c_extensions/CEllipticalCylinderModel.c
rae3ce4e r9316609 1 /** CEllipticalCylinderModel1 /** [PYTHONCLASS] 2 2 * 3 3 * C extension … … 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * CEllipticalCylinderModelError = NULL;22 static PyObject * [PYTHONCLASS]Error = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 EllipticalCylinderParameters model_pars; 34 } CEllipticalCylinderModel;34 } [PYTHONCLASS]; 35 35 36 36 37 37 static void 38 CEllipticalCylinderModel_dealloc(CEllipticalCylinderModel* self)38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 CEllipticalCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 CEllipticalCylinderModel*self;48 [PYTHONCLASS] *self; 49 49 50 self = ( CEllipticalCylinderModel*)type->tp_alloc(type, 0);50 self = ([PYTHONCLASS] *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 CEllipticalCylinderModel_init(CEllipticalCylinderModel*self, PyObject *args, PyObject *kwds)56 [PYTHONCLASS]_init([PYTHONCLASS] *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 82 82 } 83 83 84 static PyMemberDef CEllipticalCylinderModel_members[] = {85 {"params", T_OBJECT, offsetof( CEllipticalCylinderModel, params), 0,84 static PyMemberDef [PYTHONCLASS]_members[] = { 85 {"params", T_OBJECT, offsetof([PYTHONCLASS], params), 0, 86 86 "Parameters"}, 87 {"log", T_OBJECT, offsetof( CEllipticalCylinderModel, log), 0,87 {"log", T_OBJECT, offsetof([PYTHONCLASS], log), 0, 88 88 "Log"}, 89 89 {NULL} /* Sentinel */ … … 94 94 @return double 95 95 */ 96 double CEllipticalCylinderModel_readDouble(PyObject *p) {96 double [PYTHONCLASS]_readDouble(PyObject *p) { 97 97 if (PyFloat_Check(p)==1) { 98 98 return (double)(((PyFloatObject *)(p))->ob_fval); … … 112 112 * @return: function value 113 113 */ 114 static PyObject * run( CEllipticalCylinderModel*self, PyObject *args) {114 static PyObject * run([PYTHONCLASS] *self, PyObject *args) { 115 115 double q_value, phi_value; 116 116 PyObject* pars; … … 133 133 // Get input and determine whether we have to supply a 1D or 2D return value. 134 134 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 135 PyErr_SetString( CEllipticalCylinderModelError,136 " CEllipticalCylinderModel.run expects a q value.");135 PyErr_SetString([PYTHONCLASS]Error, 136 "[PYTHONCLASS].run expects a q value."); 137 137 return NULL; 138 138 } … … 144 144 npars = PyList_GET_SIZE(pars); 145 145 if(npars!=2) { 146 PyErr_SetString( CEllipticalCylinderModelError,147 " CEllipticalCylinderModel.run expects a double or a list of dimension 2.");146 PyErr_SetString([PYTHONCLASS]Error, 147 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 148 148 return NULL; 149 149 } 150 150 // We have a vector q, get the q and phi values at which 151 151 // to evaluate I(q,phi) 152 q_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,0));153 phi_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,1));152 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 153 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 154 154 // Skip zero 155 155 if (q_value==0) { … … 161 161 162 162 // We have a scalar q, we will evaluate I(q) 163 q_value = CEllipticalCylinderModel_readDouble(pars);163 q_value = [PYTHONCLASS]_readDouble(pars); 164 164 165 165 return Py_BuildValue("d",elliptical_cylinder_analytical_1D(&(self->model_pars),q_value)); … … 172 172 * @return: function value 173 173 */ 174 static PyObject * runXY( CEllipticalCylinderModel*self, PyObject *args) {174 static PyObject * runXY([PYTHONCLASS] *self, PyObject *args) { 175 175 double qx_value, qy_value; 176 176 PyObject* pars; … … 193 193 // Get input and determine whether we have to supply a 1D or 2D return value. 194 194 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 195 PyErr_SetString( CEllipticalCylinderModelError,196 " CEllipticalCylinderModel.run expects a q value.");195 PyErr_SetString([PYTHONCLASS]Error, 196 "[PYTHONCLASS].run expects a q value."); 197 197 return NULL; 198 198 } … … 204 204 npars = PyList_GET_SIZE(pars); 205 205 if(npars!=2) { 206 PyErr_SetString( CEllipticalCylinderModelError,207 " CEllipticalCylinderModel.run expects a double or a list of dimension 2.");206 PyErr_SetString([PYTHONCLASS]Error, 207 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 208 208 return NULL; 209 209 } 210 210 // We have a vector q, get the qx and qy values at which 211 211 // to evaluate I(qx,qy) 212 qx_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,0));213 qy_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,1));212 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 213 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 214 214 return Py_BuildValue("d",elliptical_cylinder_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 215 215 … … 217 217 218 218 // We have a scalar q, we will evaluate I(q) 219 qx_value = CEllipticalCylinderModel_readDouble(pars);219 qx_value = [PYTHONCLASS]_readDouble(pars); 220 220 221 221 return Py_BuildValue("d",elliptical_cylinder_analytical_1D(&(self->model_pars),qx_value)); … … 223 223 } 224 224 225 static PyObject * reset( CEllipticalCylinderModel*self, PyObject *args) {225 static PyObject * reset([PYTHONCLASS] *self, PyObject *args) { 226 226 227 227 … … 230 230 231 231 232 static PyMethodDef CEllipticalCylinderModel_methods[] = {232 static PyMethodDef [PYTHONCLASS]_methods[] = { 233 233 {"run", (PyCFunction)run , METH_VARARGS, 234 234 "Evaluate the model at a given Q or Q, phi"}, … … 242 242 }; 243 243 244 static PyTypeObject CEllipticalCylinderModelType = {244 static PyTypeObject [PYTHONCLASS]Type = { 245 245 PyObject_HEAD_INIT(NULL) 246 246 0, /*ob_size*/ 247 " CEllipticalCylinderModel", /*tp_name*/248 sizeof( CEllipticalCylinderModel), /*tp_basicsize*/247 "[PYTHONCLASS]", /*tp_name*/ 248 sizeof([PYTHONCLASS]), /*tp_basicsize*/ 249 249 0, /*tp_itemsize*/ 250 (destructor) CEllipticalCylinderModel_dealloc, /*tp_dealloc*/250 (destructor)[PYTHONCLASS]_dealloc, /*tp_dealloc*/ 251 251 0, /*tp_print*/ 252 252 0, /*tp_getattr*/ … … 264 264 0, /*tp_as_buffer*/ 265 265 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 266 " CEllipticalCylinderModelobjects", /* tp_doc */266 "[PYTHONCLASS] objects", /* tp_doc */ 267 267 0, /* tp_traverse */ 268 268 0, /* tp_clear */ … … 271 271 0, /* tp_iter */ 272 272 0, /* tp_iternext */ 273 CEllipticalCylinderModel_methods, /* tp_methods */274 CEllipticalCylinderModel_members, /* tp_members */273 [PYTHONCLASS]_methods, /* tp_methods */ 274 [PYTHONCLASS]_members, /* tp_members */ 275 275 0, /* tp_getset */ 276 276 0, /* tp_base */ … … 279 279 0, /* tp_descr_set */ 280 280 0, /* tp_dictoffset */ 281 (initproc) CEllipticalCylinderModel_init, /* tp_init */281 (initproc)[PYTHONCLASS]_init, /* tp_init */ 282 282 0, /* tp_alloc */ 283 CEllipticalCylinderModel_new, /* tp_new */283 [PYTHONCLASS]_new, /* tp_new */ 284 284 }; 285 285 … … 293 293 * @param module: module to add the class to 294 294 */ 295 void add CEllipticalCylinderModel(PyObject *module) {295 void add[PYTHONCLASS](PyObject *module) { 296 296 PyObject *d; 297 297 298 if (PyType_Ready(& CEllipticalCylinderModelType) < 0)298 if (PyType_Ready(&[PYTHONCLASS]Type) < 0) 299 299 return; 300 300 301 Py_INCREF(& CEllipticalCylinderModelType);302 PyModule_AddObject(module, " CEllipticalCylinderModel", (PyObject *)&CEllipticalCylinderModelType);301 Py_INCREF(&[PYTHONCLASS]Type); 302 PyModule_AddObject(module, "[PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type); 303 303 304 304 d = PyModule_GetDict(module); 305 CEllipticalCylinderModelError = PyErr_NewException("CEllipticalCylinderModel.error", NULL, NULL);306 PyDict_SetItemString(d, " CEllipticalCylinderModelError", CEllipticalCylinderModelError);307 } 308 305 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL); 306 PyDict_SetItemString(d, "[PYTHONCLASS]Error", [PYTHONCLASS]Error); 307 } 308 -
sansmodels/src/sans/models/c_extensions/CSphereModel.c
rae3ce4e r9316609 1 /** CSphereModel1 /** [PYTHONCLASS] 2 2 * 3 3 * C extension … … 20 20 21 21 /// Error object for raised exceptions 22 static PyObject * CSphereModelError = NULL;22 static PyObject * [PYTHONCLASS]Error = NULL; 23 23 24 24 … … 32 32 /// Model parameters 33 33 SphereParameters model_pars; 34 } CSphereModel;34 } [PYTHONCLASS]; 35 35 36 36 37 37 static void 38 CSphereModel_dealloc(CSphereModel* self)38 [PYTHONCLASS]_dealloc([PYTHONCLASS]* self) 39 39 { 40 40 self->ob_type->tp_free((PyObject*)self); … … 44 44 45 45 static PyObject * 46 CSphereModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)46 [PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 47 47 { 48 CSphereModel*self;49 50 self = ( CSphereModel*)type->tp_alloc(type, 0);48 [PYTHONCLASS] *self; 49 50 self = ([PYTHONCLASS] *)type->tp_alloc(type, 0); 51 51 52 52 return (PyObject *)self; … … 54 54 55 55 static int 56 CSphereModel_init(CSphereModel*self, PyObject *args, PyObject *kwds)56 [PYTHONCLASS]_init([PYTHONCLASS] *self, PyObject *args, PyObject *kwds) 57 57 { 58 58 if (self != NULL) { … … 77 77 } 78 78 79 static PyMemberDef CSphereModel_members[] = {80 {"params", T_OBJECT, offsetof( CSphereModel, params), 0,79 static PyMemberDef [PYTHONCLASS]_members[] = { 80 {"params", T_OBJECT, offsetof([PYTHONCLASS], params), 0, 81 81 "Parameters"}, 82 {"log", T_OBJECT, offsetof( CSphereModel, log), 0,82 {"log", T_OBJECT, offsetof([PYTHONCLASS], log), 0, 83 83 "Log"}, 84 84 {NULL} /* Sentinel */ … … 89 89 @return double 90 90 */ 91 double CSphereModel_readDouble(PyObject *p) {91 double [PYTHONCLASS]_readDouble(PyObject *p) { 92 92 if (PyFloat_Check(p)==1) { 93 93 return (double)(((PyFloatObject *)(p))->ob_fval); … … 107 107 * @return: function value 108 108 */ 109 static PyObject * run( CSphereModel*self, PyObject *args) {109 static PyObject * run([PYTHONCLASS] *self, PyObject *args) { 110 110 double q_value, phi_value; 111 111 PyObject* pars; … … 123 123 // Get input and determine whether we have to supply a 1D or 2D return value. 124 124 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 125 PyErr_SetString( CSphereModelError,126 " CSphereModel.run expects a q value.");125 PyErr_SetString([PYTHONCLASS]Error, 126 "[PYTHONCLASS].run expects a q value."); 127 127 return NULL; 128 128 } … … 134 134 npars = PyList_GET_SIZE(pars); 135 135 if(npars!=2) { 136 PyErr_SetString( CSphereModelError,137 " CSphereModel.run expects a double or a list of dimension 2.");136 PyErr_SetString([PYTHONCLASS]Error, 137 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 138 138 return NULL; 139 139 } 140 140 // We have a vector q, get the q and phi values at which 141 141 // to evaluate I(q,phi) 142 q_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,0));143 phi_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,1));142 q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 143 phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 144 144 // Skip zero 145 145 if (q_value==0) { … … 151 151 152 152 // We have a scalar q, we will evaluate I(q) 153 q_value = CSphereModel_readDouble(pars);153 q_value = [PYTHONCLASS]_readDouble(pars); 154 154 155 155 return Py_BuildValue("d",sphere_analytical_1D(&(self->model_pars),q_value)); … … 162 162 * @return: function value 163 163 */ 164 static PyObject * runXY( CSphereModel*self, PyObject *args) {164 static PyObject * runXY([PYTHONCLASS] *self, PyObject *args) { 165 165 double qx_value, qy_value; 166 166 PyObject* pars; … … 178 178 // Get input and determine whether we have to supply a 1D or 2D return value. 179 179 if ( !PyArg_ParseTuple(args,"O",&pars) ) { 180 PyErr_SetString( CSphereModelError,181 " CSphereModel.run expects a q value.");180 PyErr_SetString([PYTHONCLASS]Error, 181 "[PYTHONCLASS].run expects a q value."); 182 182 return NULL; 183 183 } … … 189 189 npars = PyList_GET_SIZE(pars); 190 190 if(npars!=2) { 191 PyErr_SetString( CSphereModelError,192 " CSphereModel.run expects a double or a list of dimension 2.");191 PyErr_SetString([PYTHONCLASS]Error, 192 "[PYTHONCLASS].run expects a double or a list of dimension 2."); 193 193 return NULL; 194 194 } 195 195 // We have a vector q, get the qx and qy values at which 196 196 // to evaluate I(qx,qy) 197 qx_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,0));198 qy_value = CSphereModel_readDouble(PyList_GET_ITEM(pars,1));197 qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 198 qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 199 199 return Py_BuildValue("d",sphere_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 200 200 … … 202 202 203 203 // We have a scalar q, we will evaluate I(q) 204 qx_value = CSphereModel_readDouble(pars);204 qx_value = [PYTHONCLASS]_readDouble(pars); 205 205 206 206 return Py_BuildValue("d",sphere_analytical_1D(&(self->model_pars),qx_value)); … … 208 208 } 209 209 210 static PyObject * reset( CSphereModel*self, PyObject *args) {210 static PyObject * reset([PYTHONCLASS] *self, PyObject *args) { 211 211 212 212 … … 215 215 216 216 217 static PyMethodDef CSphereModel_methods[] = {217 static PyMethodDef [PYTHONCLASS]_methods[] = { 218 218 {"run", (PyCFunction)run , METH_VARARGS, 219 219 "Evaluate the model at a given Q or Q, phi"}, … … 227 227 }; 228 228 229 static PyTypeObject CSphereModelType = {229 static PyTypeObject [PYTHONCLASS]Type = { 230 230 PyObject_HEAD_INIT(NULL) 231 231 0, /*ob_size*/ 232 " CSphereModel", /*tp_name*/233 sizeof( CSphereModel), /*tp_basicsize*/232 "[PYTHONCLASS]", /*tp_name*/ 233 sizeof([PYTHONCLASS]), /*tp_basicsize*/ 234 234 0, /*tp_itemsize*/ 235 (destructor) CSphereModel_dealloc, /*tp_dealloc*/235 (destructor)[PYTHONCLASS]_dealloc, /*tp_dealloc*/ 236 236 0, /*tp_print*/ 237 237 0, /*tp_getattr*/ … … 249 249 0, /*tp_as_buffer*/ 250 250 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 251 " CSphereModelobjects", /* tp_doc */251 "[PYTHONCLASS] objects", /* tp_doc */ 252 252 0, /* tp_traverse */ 253 253 0, /* tp_clear */ … … 256 256 0, /* tp_iter */ 257 257 0, /* tp_iternext */ 258 CSphereModel_methods, /* tp_methods */259 CSphereModel_members, /* tp_members */258 [PYTHONCLASS]_methods, /* tp_methods */ 259 [PYTHONCLASS]_members, /* tp_members */ 260 260 0, /* tp_getset */ 261 261 0, /* tp_base */ … … 264 264 0, /* tp_descr_set */ 265 265 0, /* tp_dictoffset */ 266 (initproc) CSphereModel_init, /* tp_init */266 (initproc)[PYTHONCLASS]_init, /* tp_init */ 267 267 0, /* tp_alloc */ 268 CSphereModel_new, /* tp_new */268 [PYTHONCLASS]_new, /* tp_new */ 269 269 }; 270 270 … … 278 278 * @param module: module to add the class to 279 279 */ 280 void add CSphereModel(PyObject *module) {280 void add[PYTHONCLASS](PyObject *module) { 281 281 PyObject *d; 282 282 283 if (PyType_Ready(& CSphereModelType) < 0)283 if (PyType_Ready(&[PYTHONCLASS]Type) < 0) 284 284 return; 285 285 286 Py_INCREF(& CSphereModelType);287 PyModule_AddObject(module, " CSphereModel", (PyObject *)&CSphereModelType);286 Py_INCREF(&[PYTHONCLASS]Type); 287 PyModule_AddObject(module, "[PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type); 288 288 289 289 d = PyModule_GetDict(module); 290 CSphereModelError = PyErr_NewException("CSphereModel.error", NULL, NULL);291 PyDict_SetItemString(d, " CSphereModelError", CSphereModelError);292 } 293 290 [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL); 291 PyDict_SetItemString(d, "[PYTHONCLASS]Error", [PYTHONCLASS]Error); 292 } 293 -
sansmodels/src/sans/models/c_extensions/WrapperGenerator.py
r4d3acb6 r9316609 131 131 self.description=temp[0] 132 132 break 133 print self.description133 #print self.description 134 134 else: 135 135 self.description=temp … … 147 147 break 148 148 else: 149 if re.search("*",line)!=None:150 temp=line.split("//",1)151 self.description+='\n'+temp[1].lstrip().rstrip()149 #if re.search("*",line)!=None: 150 # temp=line.split("*",1) 151 # self.description+='\n'+temp[1].lstrip().rstrip() 152 152 if re.search("//",line)!=None: 153 153 temp=line.split("//",1) 154 self.description+='\n '+temp[1].lstrip().rstrip()154 self.description+='\n\t\t'+temp[1].lstrip().rstrip() 155 155 156 156 else: 157 self.description+='\n '+line.lstrip().rstrip()157 self.description+='\n\t\t'+line.lstrip().rstrip() 158 158 159 159 … … 224 224 if line.count(key)>0: 225 225 self.modelCalcFlag = True 226 226 227 227 228 228 … … 244 244 newline = self.replaceToken(tmp_line, 245 245 "[PYTHONCLASS]", 'C'+self.pythonClass) 246 246 ##catch description 247 #newline = self.replaceToken(tmp_line, 248 # "[DESCRIPTION]", self.description) 247 249 # Catch class name 248 250 newline = self.replaceToken(newline, … … 336 338 newline = self.replaceToken(newline, 337 339 "[PAR_DETAILS]", self.details) 338 340 #print"write",tmp_line 339 341 # Write new line to the wrapper .c file 340 342 file.write(newline+'\n') 341 343 342 344 file.close() 343 345 -
sansmodels/src/sans/models/c_extensions/modelTemplate.txt
rae3ce4e r9316609 31 31 ## Name of the model 32 32 self.name = "[PYTHONCLASS]" 33 33 self.description= """[DESCRIPTION]""" 34 34 [PAR_DETAILS] 35 35 -
sansmodels/src/sans/models/c_models/WrapperGenerator.py
r96672c0 r9316609 109 109 # Catch Description 110 110 key = "[DESCRIPTION]" 111 find_description= False111 find_description= 0 112 112 temp="" 113 113 for line in lines: 114 114 if line.count(key)>0 : 115 find_description= True115 116 116 try: 117 find_description= 1 117 118 index = line.index(key) 118 119 toks = line[index:].split("=",1 ) 119 120 temp=toks[1].lstrip().rstrip() 120 121 text='text' 121 key2="<%s>"%text.lower 122 key2="<%s>"%text.lower() 122 123 if re.match(key2,temp)!=None: 123 index2 = line.index(key2) 124 temp=line[index:] 124 #index2 = line.index(key2) 125 #temp = temp[index2:] 126 toks2=temp.split(key2,1) 127 self.description=toks2[1] 128 text='text' 129 key2="</%s>"%text.lower() 130 if re.search(key2,toks2[1])!=None: 131 temp=toks2[1].split(key2,1) 132 self.description=temp[0] 133 break 134 #print self.description 125 135 else: 126 136 self.description=temp 137 break 127 138 except: 128 139 raise ValueError, "Could not parse file %s" % self.file 129 if find_description: 130 text='text' 131 key2="</%s>"%text.lower 132 if re.match(key2,temp)!=None: 133 index2 = line.index(key2) 134 temp=line[:index] 135 temp+=line 136 self.description= temp 140 elif find_description==1: 141 text='text' 142 key2="</%s>"%text.lower() 143 #print "second line",line,key2,re.search(key2,line) 144 if re.search(key2,line)!=None: 145 tok=line.split(key2,1) 146 temp=tok[0].split("//",1) 147 self.description+=tok[1].lstrip().rstrip() 148 break 149 else: 150 #if re.search("*",line)!=None: 151 # temp=line.split("*",1) 152 # self.description+='\n'+temp[1].lstrip().rstrip() 153 if re.search("//",line)!=None: 154 temp=line.split("//",1) 155 self.description+='\n\t\t'+temp[1].lstrip().rstrip() 156 157 else: 158 self.description+='\n\t\t'+line.lstrip().rstrip() 159 160 137 161 138 162 for line in lines: … … 235 259 newline = self.replaceToken(tmp_line, 236 260 "[PYTHONCLASS]", 'C'+self.pythonClass) 237 261 #Catch model description 262 newline = self.replaceToken(tmp_line, 263 "[DESCRIPTION]", self.description) 238 264 # Catch C model name 239 265 newline = self.replaceToken(newline, -
sansmodels/src/sans/models/c_models/modelTemplate.txt
r8809e48 r9316609 43 43 ## Name of the model 44 44 self.name = "[PYTHONCLASS]" 45 45 self.description ="""[DESCRIPTION]""" 46 46 [PAR_DETAILS] 47 47
Note: See TracChangeset
for help on using the changeset viewer.