source: sasview/src/sans/models/c_extension/python_wrapper/generated/CSLDCalFunc.cpp @ 400155b

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 400155b was 400155b, checked in by gonzalezm, 9 years ago

Implementing request from ticket 261 - default number of bins in Annulus [Phi View] is now 36 and the first bin is now centered at 0 degrees

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