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