source: sasview/sansmodels/src/sans/models/c_models/CFlexibleCylinderModel.cpp @ 1d67243

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 1d67243 was 9bd69098, checked in by Jae Cho <jhjcho@…>, 15 years ago

recompiled all due to Alina's new eval(run) function

  • Property mode set to 100644
File size: 21.8 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, University of Tennessee
13 */
14
15/** CFlexibleCylinderModel
16 *
17 * C extension
18 *
19 * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
20 *          DO NOT MODIFY THIS FILE, MODIFY flexible_cylinder.h
21 *          AND RE-RUN THE GENERATOR SCRIPT
22 *
23 */
24#define NO_IMPORT_ARRAY
25#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
26 
27extern "C" {
28#include <Python.h>
29#include <arrayobject.h>
30#include "structmember.h"
31#include <stdio.h>
32#include <stdlib.h>
33#include <math.h>
34#include <time.h>
35#include "flexible_cylinder.h"
36}
37
38#include "models.hh"
39#include "dispersion_visitor.hh"
40
41/// Error object for raised exceptions
42static PyObject * CFlexibleCylinderModelError = NULL;
43
44
45// Class definition
46typedef struct {
47    PyObject_HEAD
48    /// Parameters
49    PyObject * params;
50    /// Dispersion parameters
51    PyObject * dispersion;
52    /// Underlying model object
53    FlexibleCylinderModel * model;
54    /// Log for unit testing
55    PyObject * log;
56} CFlexibleCylinderModel;
57
58
59static void
60CFlexibleCylinderModel_dealloc(CFlexibleCylinderModel* self)
61{
62    self->ob_type->tp_free((PyObject*)self);
63   
64
65}
66
67static PyObject *
68CFlexibleCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
69{
70    CFlexibleCylinderModel *self;
71   
72    self = (CFlexibleCylinderModel *)type->tp_alloc(type, 0);
73   
74    return (PyObject *)self;
75}
76
77static int
78CFlexibleCylinderModel_init(CFlexibleCylinderModel *self, PyObject *args, PyObject *kwds)
79{
80    if (self != NULL) {
81       
82        // Create parameters
83        self->params = PyDict_New();
84        self->dispersion = PyDict_New();
85        self->model = new FlexibleCylinderModel();
86       
87        // Initialize parameter dictionary
88        PyDict_SetItemString(self->params,"scale",Py_BuildValue("d",1.000000));
89        PyDict_SetItemString(self->params,"length",Py_BuildValue("d",1000.000000));
90        PyDict_SetItemString(self->params,"radius",Py_BuildValue("d",20.000000));
91        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.000100));
92        PyDict_SetItemString(self->params,"kuhn_length",Py_BuildValue("d",100.000000));
93        PyDict_SetItemString(self->params,"contrast",Py_BuildValue("d",0.000005));
94        // Initialize dispersion / averaging parameter dict
95        DispersionVisitor* visitor = new DispersionVisitor();
96        PyObject * disp_dict;
97        disp_dict = PyDict_New();
98        self->model->length.dispersion->accept_as_source(visitor, self->model->length.dispersion, disp_dict);
99        PyDict_SetItemString(self->dispersion, "length", disp_dict);
100        disp_dict = PyDict_New();
101        self->model->kuhn_length.dispersion->accept_as_source(visitor, self->model->kuhn_length.dispersion, disp_dict);
102        PyDict_SetItemString(self->dispersion, "kuhn_length", disp_dict);
103        disp_dict = PyDict_New();
104        self->model->radius.dispersion->accept_as_source(visitor, self->model->radius.dispersion, disp_dict);
105        PyDict_SetItemString(self->dispersion, "radius", disp_dict);
106
107
108         
109        // Create empty log
110        self->log = PyDict_New();
111       
112       
113
114    }
115    return 0;
116}
117
118static PyMemberDef CFlexibleCylinderModel_members[] = {
119    {"params", T_OBJECT, offsetof(CFlexibleCylinderModel, params), 0,
120     "Parameters"},
121        {"dispersion", T_OBJECT, offsetof(CFlexibleCylinderModel, dispersion), 0,
122          "Dispersion parameters"},     
123    {"log", T_OBJECT, offsetof(CFlexibleCylinderModel, log), 0,
124     "Log"},
125    {NULL}  /* Sentinel */
126};
127
128/** Read double from PyObject
129    @param p PyObject
130    @return double
131*/
132double CFlexibleCylinderModel_readDouble(PyObject *p) {
133    if (PyFloat_Check(p)==1) {
134        return (double)(((PyFloatObject *)(p))->ob_fval);
135    } else if (PyInt_Check(p)==1) {
136        return (double)(((PyIntObject *)(p))->ob_ival);
137    } else if (PyLong_Check(p)==1) {
138        return (double)PyLong_AsLong(p);
139    } else {
140        return 0.0;
141    }
142}
143/**
144 * Function to call to evaluate model
145 * @param args: input numpy array q[]
146 * @return: numpy array object
147 */
148 
149static PyObject *evaluateOneDim(FlexibleCylinderModel* model, PyArrayObject *q){
150    PyArrayObject *result;
151   
152    // Check validity of array q , q must be of dimension 1, an array of double
153    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE)
154    {
155        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
156        //PyErr_SetString(PyExc_ValueError , message);
157        return NULL;
158    }
159    result = (PyArrayObject *)PyArray_FromDims(q->nd, (int *)(q->dimensions), 
160                                                                                  PyArray_DOUBLE);
161        if (result == NULL) {
162        const char * message= "Could not create result ";
163        PyErr_SetString(PyExc_RuntimeError , message);
164                return NULL;
165        }
166         for (int i = 0; i < q->dimensions[0]; i++){
167      double q_value  = *(double *)(q->data + i*q->strides[0]);
168      double *result_value = (double *)(result->data + i*result->strides[0]);
169      *result_value =(*model)(q_value);
170        }
171    return PyArray_Return(result); 
172 }
173/**
174 * Function to call to evaluate model
175 * @param args: input numpy array  [q[],phi[]]
176 * @return: numpy array object
177 */
178static PyObject * evaluateTwoDim( FlexibleCylinderModel* model, 
179                              PyArrayObject *q, PyArrayObject *phi)
180 {
181    PyArrayObject *result;
182    //check validity of input vectors
183    if (q->nd != 1 || q->descr->type_num != PyArray_DOUBLE
184        || phi->nd != 1 || phi->descr->type_num != PyArray_DOUBLE
185        || phi->dimensions[0] != q->dimensions[0]){
186     
187        //const char * message= "Invalid array: q->nd=%d,type_num=%d\n",q->nd,q->descr->type_num;
188        PyErr_SetString(PyExc_ValueError ,"wrong input"); 
189        return NULL;
190    }
191        result= (PyArrayObject *)PyArray_FromDims(q->nd,(int*)(q->dimensions), PyArray_DOUBLE);
192
193        if (result == NULL){
194            const char * message= "Could not create result ";
195        PyErr_SetString(PyExc_RuntimeError , message);
196            return NULL;
197        }
198       
199    for (int i = 0; i < q->dimensions[0]; i++) {
200      double q_value = *(double *)(q->data + i*q->strides[0]);
201      double phi_value = *(double *)(phi->data + i*phi->strides[0]);
202      double *result_value = (double *)(result->data + i*result->strides[0]);
203      if (q_value == 0)
204          *result_value = 0.0;
205      else
206          *result_value = model->evaluate_rphi(q_value, phi_value);
207    }
208    return PyArray_Return(result); 
209 }
210 /**
211 * Function to call to evaluate model
212 * @param args: input numpy array  [x[],y[]]
213 * @return: numpy array object
214 */
215 static PyObject * evaluateTwoDimXY( FlexibleCylinderModel* model, 
216                              PyArrayObject *x, PyArrayObject *y)
217 {
218    PyArrayObject *result;
219    int i,j, x_len, y_len, dims[2];
220    //check validity of input vectors
221    if (x->nd != 2 || x->descr->type_num != PyArray_DOUBLE
222        || y->nd != 2 || y->descr->type_num != PyArray_DOUBLE
223        || y->dimensions[1] != x->dimensions[0]){
224        const char * message= "evaluateTwoDimXY  expect 2 numpy arrays";
225        PyErr_SetString(PyExc_ValueError , message); 
226        return NULL;
227    }
228   
229        if (PyArray_Check(x) && PyArray_Check(y)) {
230            x_len = dims[0]= x->dimensions[0];
231        y_len = dims[1]= y->dimensions[1];
232           
233            // Make a new double matrix of same dims
234        result=(PyArrayObject *) PyArray_FromDims(2,dims,NPY_DOUBLE);
235        if (result == NULL){
236            const char * message= "Could not create result ";
237        PyErr_SetString(PyExc_RuntimeError , message);
238            return NULL;
239            }
240       
241        /* Do the calculation. */
242        for ( i=0; i< x_len; i++) {
243            for ( j=0; j< y_len; j++) {
244                double x_value = *(double *)(x->data + i*x->strides[0]);
245                    double y_value = *(double *)(y->data + j*y->strides[1]);
246                        double *result_value = (double *)(result->data +
247                              i*result->strides[0] + j*result->strides[1]);
248                        *result_value = (*model)(x_value, y_value);
249            }           
250        }
251        return PyArray_Return(result); 
252       
253        }else{
254                    PyErr_SetString(CFlexibleCylinderModelError, 
255                   "CFlexibleCylinderModel.evaluateTwoDimXY couldn't run.");
256                return NULL;
257                }       
258}
259/**
260 *  evalDistribution function evaluate a model function with input vector
261 *  @param args: input q as vector or [qx, qy] where qx, qy are vectors
262 *
263 */ 
264static PyObject * evalDistribution(CFlexibleCylinderModel *self, PyObject *args){
265        PyObject *qx, *qy;
266        PyArrayObject * pars;
267        int npars ,mpars;
268       
269        // Get parameters
270       
271            // Reader parameter dictionary
272    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
273    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
274    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
275    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
276    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
277    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") );
278    // Read in dispersion parameters
279    PyObject* disp_dict;
280    DispersionVisitor* visitor = new DispersionVisitor();
281    disp_dict = PyDict_GetItemString(self->dispersion, "length");
282    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
283    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
284    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
285    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
286    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
287
288       
289        // Get input and determine whether we have to supply a 1D or 2D return value.
290        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
291            PyErr_SetString(CFlexibleCylinderModelError, 
292                "CFlexibleCylinderModel.evalDistribution expects a q value.");
293                return NULL;
294        }
295    // Check params
296       
297    if(PyArray_Check(pars)==1) {
298               
299            // Length of list should 1 or 2
300            npars = pars->nd; 
301            if(npars==1) {
302                // input is a numpy array
303                if (PyArray_Check(pars)) {
304                        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
305                    }
306                }else{
307                    PyErr_SetString(CFlexibleCylinderModelError, 
308                   "CFlexibleCylinderModel.evalDistribution expect numpy array of one dimension.");
309                return NULL;
310                }
311    }else if( PyList_Check(pars)==1) {
312        // Length of list should be 2 for I(qx,qy)
313            mpars = PyList_GET_SIZE(pars); 
314            if(mpars!=2) {
315                PyErr_SetString(CFlexibleCylinderModelError, 
316                        "CFlexibleCylinderModel.evalDistribution expects a list of dimension 2.");
317                return NULL;
318            }
319             qx = PyList_GET_ITEM(pars,0);
320             qy = PyList_GET_ITEM(pars,1);
321             if (PyArray_Check(qx) && PyArray_Check(qy)) {
322                 return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
323                           (PyArrayObject*)qy);
324                 }else{
325                    PyErr_SetString(CFlexibleCylinderModelError, 
326                   "CFlexibleCylinderModel.evalDistribution expect 2 numpy arrays in list.");
327                return NULL;
328             }
329        }else{
330            PyErr_SetString(CFlexibleCylinderModelError, 
331                   "CFlexibleCylinderModel.evalDistribution couln't be run.");
332            return NULL;
333        }
334}
335
336/**
337 * Function to call to evaluate model
338 * @param args: input q or [q,phi]
339 * @return: function value
340 */
341static PyObject * run(CFlexibleCylinderModel *self, PyObject *args) {
342        double q_value, phi_value;
343        PyObject* pars;
344        int npars;
345       
346        // Get parameters
347       
348            // Reader parameter dictionary
349    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
350    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
351    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
352    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
353    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
354    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") );
355    // Read in dispersion parameters
356    PyObject* disp_dict;
357    DispersionVisitor* visitor = new DispersionVisitor();
358    disp_dict = PyDict_GetItemString(self->dispersion, "length");
359    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
360    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
361    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
362    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
363    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
364
365       
366        // Get input and determine whether we have to supply a 1D or 2D return value.
367        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
368            PyErr_SetString(CFlexibleCylinderModelError, 
369                "CFlexibleCylinderModel.run expects a q value.");
370                return NULL;
371        }
372         
373        // Check params
374        if( PyList_Check(pars)==1) {
375               
376                // Length of list should be 2 for I(q,phi)
377            npars = PyList_GET_SIZE(pars); 
378            if(npars!=2) {
379                PyErr_SetString(CFlexibleCylinderModelError, 
380                        "CFlexibleCylinderModel.run expects a double or a list of dimension 2.");
381                return NULL;
382            }
383            // We have a vector q, get the q and phi values at which
384            // to evaluate I(q,phi)
385            q_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
386            phi_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
387            // Skip zero
388            if (q_value==0) {
389                return Py_BuildValue("d",0.0);
390            }
391                return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
392
393        } else {
394
395                // We have a scalar q, we will evaluate I(q)
396                q_value = CFlexibleCylinderModel_readDouble(pars);             
397               
398                return Py_BuildValue("d",(*(self->model))(q_value));
399        }       
400}
401
402/**
403 * Function to call to evaluate model in cartesian coordinates
404 * @param args: input q or [qx, qy]]
405 * @return: function value
406 */
407static PyObject * runXY(CFlexibleCylinderModel *self, PyObject *args) {
408        double qx_value, qy_value;
409        PyObject* pars;
410        int npars;
411       
412        // Get parameters
413       
414            // Reader parameter dictionary
415    self->model->scale = PyFloat_AsDouble( PyDict_GetItemString(self->params, "scale") );
416    self->model->length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "length") );
417    self->model->radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "radius") );
418    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
419    self->model->kuhn_length = PyFloat_AsDouble( PyDict_GetItemString(self->params, "kuhn_length") );
420    self->model->contrast = PyFloat_AsDouble( PyDict_GetItemString(self->params, "contrast") );
421    // Read in dispersion parameters
422    PyObject* disp_dict;
423    DispersionVisitor* visitor = new DispersionVisitor();
424    disp_dict = PyDict_GetItemString(self->dispersion, "length");
425    self->model->length.dispersion->accept_as_destination(visitor, self->model->length.dispersion, disp_dict);
426    disp_dict = PyDict_GetItemString(self->dispersion, "kuhn_length");
427    self->model->kuhn_length.dispersion->accept_as_destination(visitor, self->model->kuhn_length.dispersion, disp_dict);
428    disp_dict = PyDict_GetItemString(self->dispersion, "radius");
429    self->model->radius.dispersion->accept_as_destination(visitor, self->model->radius.dispersion, disp_dict);
430
431       
432        // Get input and determine whether we have to supply a 1D or 2D return value.
433        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
434            PyErr_SetString(CFlexibleCylinderModelError, 
435                "CFlexibleCylinderModel.run expects a q value.");
436                return NULL;
437        }
438         
439        // Check params
440        if( PyList_Check(pars)==1) {
441               
442                // Length of list should be 2 for I(qx, qy))
443            npars = PyList_GET_SIZE(pars); 
444            if(npars!=2) {
445                PyErr_SetString(CFlexibleCylinderModelError, 
446                        "CFlexibleCylinderModel.run expects a double or a list of dimension 2.");
447                return NULL;
448            }
449            // We have a vector q, get the qx and qy values at which
450            // to evaluate I(qx,qy)
451            qx_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,0));
452            qy_value = CFlexibleCylinderModel_readDouble(PyList_GET_ITEM(pars,1));
453            return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
454
455        } else {
456
457                // We have a scalar q, we will evaluate I(q)
458                qx_value = CFlexibleCylinderModel_readDouble(pars);             
459               
460                return Py_BuildValue("d",(*(self->model))(qx_value));
461        }       
462}
463
464static PyObject * reset(CFlexibleCylinderModel *self, PyObject *args) {
465   
466
467    return Py_BuildValue("d",0.0);
468}
469
470static PyObject * set_dispersion(CFlexibleCylinderModel *self, PyObject *args) {
471        PyObject * disp;
472        const char * par_name;
473
474        if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
475            PyErr_SetString(CFlexibleCylinderModelError,
476                "CFlexibleCylinderModel.set_dispersion expects a DispersionModel object.");
477                return NULL;
478        }
479        void *temp = PyCObject_AsVoidPtr(disp);
480        DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
481
482
483        // Ugliness necessary to go from python to C
484            // TODO: refactor this
485    if (!strcmp(par_name, "length")) {
486        self->model->length.dispersion = dispersion;
487    } else    if (!strcmp(par_name, "kuhn_length")) {
488        self->model->kuhn_length.dispersion = dispersion;
489    } else    if (!strcmp(par_name, "radius")) {
490        self->model->radius.dispersion = dispersion;
491    } else {
492            PyErr_SetString(CFlexibleCylinderModelError,
493                "CFlexibleCylinderModel.set_dispersion expects a valid parameter name.");
494                return NULL;
495        }
496
497        DispersionVisitor* visitor = new DispersionVisitor();
498        PyObject * disp_dict = PyDict_New();
499        dispersion->accept_as_source(visitor, dispersion, disp_dict);
500        PyDict_SetItemString(self->dispersion, par_name, disp_dict);
501    return Py_BuildValue("i",1);
502}
503
504
505static PyMethodDef CFlexibleCylinderModel_methods[] = {
506    {"run",      (PyCFunction)run     , METH_VARARGS,
507      "Evaluate the model at a given Q or Q, phi"},
508    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
509      "Evaluate the model at a given Q or Qx, Qy"},
510     
511    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
512      "Evaluate the model at a given Q or Qx, Qy vector "},
513    {"reset",    (PyCFunction)reset   , METH_VARARGS,
514      "Reset pair correlation"},
515    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
516      "Set the dispersion model for a given parameter"},
517   {NULL}
518};
519
520static PyTypeObject CFlexibleCylinderModelType = {
521    PyObject_HEAD_INIT(NULL)
522    0,                         /*ob_size*/
523    "CFlexibleCylinderModel",             /*tp_name*/
524    sizeof(CFlexibleCylinderModel),             /*tp_basicsize*/
525    0,                         /*tp_itemsize*/
526    (destructor)CFlexibleCylinderModel_dealloc, /*tp_dealloc*/
527    0,                         /*tp_print*/
528    0,                         /*tp_getattr*/
529    0,                         /*tp_setattr*/
530    0,                         /*tp_compare*/
531    0,                         /*tp_repr*/
532    0,                         /*tp_as_number*/
533    0,                         /*tp_as_sequence*/
534    0,                         /*tp_as_mapping*/
535    0,                         /*tp_hash */
536    0,                         /*tp_call*/
537    0,                         /*tp_str*/
538    0,                         /*tp_getattro*/
539    0,                         /*tp_setattro*/
540    0,                         /*tp_as_buffer*/
541    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
542    "CFlexibleCylinderModel objects",           /* tp_doc */
543    0,                         /* tp_traverse */
544    0,                         /* tp_clear */
545    0,                         /* tp_richcompare */
546    0,                         /* tp_weaklistoffset */
547    0,                         /* tp_iter */
548    0,                         /* tp_iternext */
549    CFlexibleCylinderModel_methods,             /* tp_methods */
550    CFlexibleCylinderModel_members,             /* tp_members */
551    0,                         /* tp_getset */
552    0,                         /* tp_base */
553    0,                         /* tp_dict */
554    0,                         /* tp_descr_get */
555    0,                         /* tp_descr_set */
556    0,                         /* tp_dictoffset */
557    (initproc)CFlexibleCylinderModel_init,      /* tp_init */
558    0,                         /* tp_alloc */
559    CFlexibleCylinderModel_new,                 /* tp_new */
560};
561
562
563//static PyMethodDef module_methods[] = {
564//    {NULL}
565//};
566
567/**
568 * Function used to add the model class to a module
569 * @param module: module to add the class to
570 */ 
571void addCFlexibleCylinderModel(PyObject *module) {
572        PyObject *d;
573       
574    if (PyType_Ready(&CFlexibleCylinderModelType) < 0)
575        return;
576
577    Py_INCREF(&CFlexibleCylinderModelType);
578    PyModule_AddObject(module, "CFlexibleCylinderModel", (PyObject *)&CFlexibleCylinderModelType);
579   
580    d = PyModule_GetDict(module);
581    CFlexibleCylinderModelError = PyErr_NewException("CFlexibleCylinderModel.error", NULL, NULL);
582    PyDict_SetItemString(d, "CFlexibleCylinderModelError", CFlexibleCylinderModelError);
583}
584
Note: See TracBrowser for help on using the repository browser.