source: sasview/sansmodels/src/sans/models/c_models/CBinaryHSPSF11Model.cpp @ 2e38ebb

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 2e38ebb was 71e2de7, checked in by Gervaise Alina <gervyh@…>, 15 years ago

change destructor for models

  • Property mode set to 100644
File size: 22.0 KB
RevLine 
[2c4b289]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/** CBinaryHSPSF11Model
16 *
17 * C extension
18 *
19 * WARNING: THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY
20 *          DO NOT MODIFY THIS FILE, MODIFY binaryHS_PSF11.h
21 *          AND RE-RUN THE GENERATOR SCRIPT
22 *
23 */
[9bd69098]24#define NO_IMPORT_ARRAY
25#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API_sans
[2c4b289]26 
27extern "C" {
28#include <Python.h>
[9bd69098]29#include <arrayobject.h>
[2c4b289]30#include "structmember.h"
31#include <stdio.h>
32#include <stdlib.h>
33#include <math.h>
34#include <time.h>
35#include "binaryHS_PSF11.h"
36}
37
38#include "models.hh"
39#include "dispersion_visitor.hh"
40
41/// Error object for raised exceptions
42static PyObject * CBinaryHSPSF11ModelError = 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    BinaryHSPSF11Model * model;
54    /// Log for unit testing
55    PyObject * log;
56} CBinaryHSPSF11Model;
57
58
59static void
60CBinaryHSPSF11Model_dealloc(CBinaryHSPSF11Model* self)
61{
[71e2de7]62    Py_DECREF(self->params);
63    Py_DECREF(self->dispersion);
64    Py_DECREF(self->log);
65    delete self->model;
[2c4b289]66    self->ob_type->tp_free((PyObject*)self);
67   
68
69}
70
71static PyObject *
72CBinaryHSPSF11Model_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
73{
74    CBinaryHSPSF11Model *self;
75   
76    self = (CBinaryHSPSF11Model *)type->tp_alloc(type, 0);
77   
78    return (PyObject *)self;
79}
80
81static int
82CBinaryHSPSF11Model_init(CBinaryHSPSF11Model *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        self->model = new BinaryHSPSF11Model();
90       
91        // Initialize parameter dictionary
92        PyDict_SetItemString(self->params,"vol_frac_ls",Py_BuildValue("d",0.200000));
93        PyDict_SetItemString(self->params,"background",Py_BuildValue("d",0.001000));
94        PyDict_SetItemString(self->params,"vol_frac_ss",Py_BuildValue("d",0.200000));
95        PyDict_SetItemString(self->params,"solvent_sld",Py_BuildValue("d",0.000006));
96        PyDict_SetItemString(self->params,"ls_sld",Py_BuildValue("d",0.000003));
97        PyDict_SetItemString(self->params,"ss_sld",Py_BuildValue("d",0.000000));
98        PyDict_SetItemString(self->params,"s_radius",Py_BuildValue("d",25.000000));
99        PyDict_SetItemString(self->params,"l_radius",Py_BuildValue("d",160.000000));
100        // Initialize dispersion / averaging parameter dict
101        DispersionVisitor* visitor = new DispersionVisitor();
102        PyObject * disp_dict;
103        disp_dict = PyDict_New();
104        self->model->l_radius.dispersion->accept_as_source(visitor, self->model->l_radius.dispersion, disp_dict);
105        PyDict_SetItemString(self->dispersion, "l_radius", disp_dict);
106        disp_dict = PyDict_New();
107        self->model->s_radius.dispersion->accept_as_source(visitor, self->model->s_radius.dispersion, disp_dict);
108        PyDict_SetItemString(self->dispersion, "s_radius", disp_dict);
109
110
111         
112        // Create empty log
113        self->log = PyDict_New();
114       
115       
116
117    }
118    return 0;
119}
120
121static PyMemberDef CBinaryHSPSF11Model_members[] = {
122    {"params", T_OBJECT, offsetof(CBinaryHSPSF11Model, params), 0,
123     "Parameters"},
124        {"dispersion", T_OBJECT, offsetof(CBinaryHSPSF11Model, dispersion), 0,
125          "Dispersion parameters"},     
126    {"log", T_OBJECT, offsetof(CBinaryHSPSF11Model, log), 0,
127     "Log"},
128    {NULL}  /* Sentinel */
129};
130
131/** Read double from PyObject
132    @param p PyObject
133    @return double
134*/
135double CBinaryHSPSF11Model_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}
[9bd69098]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(BinaryHSPSF11Model* 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), 
163                                                                                  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         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 }
[2c4b289]176
[9bd69098]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( BinaryHSPSF11Model* model, 
183                              PyArrayObject *x, PyArrayObject *y)
184 {
185    PyArrayObject *result;
186    int i,j, x_len, y_len, dims[2];
187    //check validity of input vectors
188    if (x->nd != 2 || x->descr->type_num != PyArray_DOUBLE
189        || y->nd != 2 || y->descr->type_num != PyArray_DOUBLE
190        || y->dimensions[1] != 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)) {
[a8d6888]197               
[9ce41c6]198            x_len = dims[1]= x->dimensions[1];
199        y_len = dims[0]= y->dimensions[0];
[9bd69098]200           
201            // Make a new double matrix of same dims
202        result=(PyArrayObject *) PyArray_FromDims(2,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. */
[e0a8a3c]210        for ( j=0; j< y_len; j++) {
211            for ( i=0; i< x_len; i++) {
[9ce41c6]212                double x_value = *(double *)(x->data + i*x->strides[1]);
213                    double y_value = *(double *)(y->data + j*y->strides[0]);
[9bd69098]214                        double *result_value = (double *)(result->data +
[870f131]215                              j*result->strides[0] + i*result->strides[1]);
[9bd69098]216                        *result_value = (*model)(x_value, y_value);
217            }           
218        }
219        return PyArray_Return(result); 
220       
221        }else{
222                    PyErr_SetString(CBinaryHSPSF11ModelError, 
223                   "CBinaryHSPSF11Model.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(CBinaryHSPSF11Model *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->vol_frac_ls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ls") );
241    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
242    self->model->vol_frac_ss = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ss") );
243    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
244    self->model->ls_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ls_sld") );
245    self->model->ss_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ss_sld") );
246    self->model->s_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_radius") );
247    self->model->l_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "l_radius") );
248    // Read in dispersion parameters
249    PyObject* disp_dict;
250    DispersionVisitor* visitor = new DispersionVisitor();
251    disp_dict = PyDict_GetItemString(self->dispersion, "l_radius");
252    self->model->l_radius.dispersion->accept_as_destination(visitor, self->model->l_radius.dispersion, disp_dict);
253    disp_dict = PyDict_GetItemString(self->dispersion, "s_radius");
254    self->model->s_radius.dispersion->accept_as_destination(visitor, self->model->s_radius.dispersion, disp_dict);
255
256       
257        // Get input and determine whether we have to supply a 1D or 2D return value.
258        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
259            PyErr_SetString(CBinaryHSPSF11ModelError, 
260                "CBinaryHSPSF11Model.evalDistribution expects a q value.");
261                return NULL;
262        }
263    // Check params
264       
265    if(PyArray_Check(pars)==1) {
266               
267            // Length of list should 1 or 2
268            npars = pars->nd; 
269            if(npars==1) {
270                // input is a numpy array
271                if (PyArray_Check(pars)) {
272                        return evaluateOneDim(self->model, (PyArrayObject*)pars); 
273                    }
274                }else{
275                    PyErr_SetString(CBinaryHSPSF11ModelError, 
276                   "CBinaryHSPSF11Model.evalDistribution expect numpy array of one dimension.");
277                return NULL;
278                }
279    }else if( PyList_Check(pars)==1) {
280        // Length of list should be 2 for I(qx,qy)
281            mpars = PyList_GET_SIZE(pars); 
282            if(mpars!=2) {
283                PyErr_SetString(CBinaryHSPSF11ModelError, 
284                        "CBinaryHSPSF11Model.evalDistribution expects a list of dimension 2.");
285                return NULL;
286            }
287             qx = PyList_GET_ITEM(pars,0);
288             qy = PyList_GET_ITEM(pars,1);
289             if (PyArray_Check(qx) && PyArray_Check(qy)) {
290                 return evaluateTwoDimXY(self->model, (PyArrayObject*)qx,
291                           (PyArrayObject*)qy);
292                 }else{
293                    PyErr_SetString(CBinaryHSPSF11ModelError, 
294                   "CBinaryHSPSF11Model.evalDistribution expect 2 numpy arrays in list.");
295                return NULL;
296             }
297        }
[e0a8a3c]298        PyErr_SetString(CBinaryHSPSF11ModelError, 
299                   "CBinaryHSPSF11Model.evalDistribution couln't be run.");
300        return NULL;
301       
[9bd69098]302}
[2c4b289]303
304/**
305 * Function to call to evaluate model
306 * @param args: input q or [q,phi]
307 * @return: function value
308 */
309static PyObject * run(CBinaryHSPSF11Model *self, PyObject *args) {
310        double q_value, phi_value;
311        PyObject* pars;
312        int npars;
313       
314        // Get parameters
315       
316            // Reader parameter dictionary
317    self->model->vol_frac_ls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ls") );
318    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
319    self->model->vol_frac_ss = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ss") );
320    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
321    self->model->ls_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ls_sld") );
322    self->model->ss_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ss_sld") );
323    self->model->s_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_radius") );
324    self->model->l_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "l_radius") );
325    // Read in dispersion parameters
326    PyObject* disp_dict;
327    DispersionVisitor* visitor = new DispersionVisitor();
328    disp_dict = PyDict_GetItemString(self->dispersion, "l_radius");
329    self->model->l_radius.dispersion->accept_as_destination(visitor, self->model->l_radius.dispersion, disp_dict);
330    disp_dict = PyDict_GetItemString(self->dispersion, "s_radius");
331    self->model->s_radius.dispersion->accept_as_destination(visitor, self->model->s_radius.dispersion, disp_dict);
332
333       
334        // Get input and determine whether we have to supply a 1D or 2D return value.
335        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
336            PyErr_SetString(CBinaryHSPSF11ModelError, 
337                "CBinaryHSPSF11Model.run expects a q value.");
338                return NULL;
339        }
340         
341        // Check params
342        if( PyList_Check(pars)==1) {
343               
344                // Length of list should be 2 for I(q,phi)
345            npars = PyList_GET_SIZE(pars); 
346            if(npars!=2) {
347                PyErr_SetString(CBinaryHSPSF11ModelError, 
348                        "CBinaryHSPSF11Model.run expects a double or a list of dimension 2.");
349                return NULL;
350            }
351            // We have a vector q, get the q and phi values at which
352            // to evaluate I(q,phi)
353            q_value = CBinaryHSPSF11Model_readDouble(PyList_GET_ITEM(pars,0));
354            phi_value = CBinaryHSPSF11Model_readDouble(PyList_GET_ITEM(pars,1));
355            // Skip zero
356            if (q_value==0) {
357                return Py_BuildValue("d",0.0);
358            }
359                return Py_BuildValue("d",(*(self->model)).evaluate_rphi(q_value,phi_value));
360
361        } else {
362
363                // We have a scalar q, we will evaluate I(q)
364                q_value = CBinaryHSPSF11Model_readDouble(pars);         
365               
366                return Py_BuildValue("d",(*(self->model))(q_value));
367        }       
368}
[5eb9154]369/**
370 * Function to call to calculate_ER
371 * @return: effective radius value
372 */
373static PyObject * calculate_ER(CBinaryHSPSF11Model *self) {
374
375        PyObject* pars;
376        int npars;
377       
378        // Get parameters
379       
380            // Reader parameter dictionary
381    self->model->vol_frac_ls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ls") );
382    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
383    self->model->vol_frac_ss = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ss") );
384    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
385    self->model->ls_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ls_sld") );
386    self->model->ss_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ss_sld") );
387    self->model->s_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_radius") );
388    self->model->l_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "l_radius") );
389    // Read in dispersion parameters
390    PyObject* disp_dict;
391    DispersionVisitor* visitor = new DispersionVisitor();
392    disp_dict = PyDict_GetItemString(self->dispersion, "l_radius");
393    self->model->l_radius.dispersion->accept_as_destination(visitor, self->model->l_radius.dispersion, disp_dict);
394    disp_dict = PyDict_GetItemString(self->dispersion, "s_radius");
395    self->model->s_radius.dispersion->accept_as_destination(visitor, self->model->s_radius.dispersion, disp_dict);
[2c4b289]396
[5eb9154]397               
398        return Py_BuildValue("d",(*(self->model)).calculate_ER());
399
400}
[2c4b289]401/**
402 * Function to call to evaluate model in cartesian coordinates
403 * @param args: input q or [qx, qy]]
404 * @return: function value
405 */
406static PyObject * runXY(CBinaryHSPSF11Model *self, PyObject *args) {
407        double qx_value, qy_value;
408        PyObject* pars;
409        int npars;
410       
411        // Get parameters
412       
413            // Reader parameter dictionary
414    self->model->vol_frac_ls = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ls") );
415    self->model->background = PyFloat_AsDouble( PyDict_GetItemString(self->params, "background") );
416    self->model->vol_frac_ss = PyFloat_AsDouble( PyDict_GetItemString(self->params, "vol_frac_ss") );
417    self->model->solvent_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "solvent_sld") );
418    self->model->ls_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ls_sld") );
419    self->model->ss_sld = PyFloat_AsDouble( PyDict_GetItemString(self->params, "ss_sld") );
420    self->model->s_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "s_radius") );
421    self->model->l_radius = PyFloat_AsDouble( PyDict_GetItemString(self->params, "l_radius") );
422    // Read in dispersion parameters
423    PyObject* disp_dict;
424    DispersionVisitor* visitor = new DispersionVisitor();
425    disp_dict = PyDict_GetItemString(self->dispersion, "l_radius");
426    self->model->l_radius.dispersion->accept_as_destination(visitor, self->model->l_radius.dispersion, disp_dict);
427    disp_dict = PyDict_GetItemString(self->dispersion, "s_radius");
428    self->model->s_radius.dispersion->accept_as_destination(visitor, self->model->s_radius.dispersion, disp_dict);
429
430       
431        // Get input and determine whether we have to supply a 1D or 2D return value.
432        if ( !PyArg_ParseTuple(args,"O",&pars) ) {
433            PyErr_SetString(CBinaryHSPSF11ModelError, 
434                "CBinaryHSPSF11Model.run expects a q value.");
435                return NULL;
436        }
437         
438        // Check params
439        if( PyList_Check(pars)==1) {
440               
441                // Length of list should be 2 for I(qx, qy))
442            npars = PyList_GET_SIZE(pars); 
443            if(npars!=2) {
444                PyErr_SetString(CBinaryHSPSF11ModelError, 
445                        "CBinaryHSPSF11Model.run expects a double or a list of dimension 2.");
446                return NULL;
447            }
448            // We have a vector q, get the qx and qy values at which
449            // to evaluate I(qx,qy)
450            qx_value = CBinaryHSPSF11Model_readDouble(PyList_GET_ITEM(pars,0));
451            qy_value = CBinaryHSPSF11Model_readDouble(PyList_GET_ITEM(pars,1));
452            return Py_BuildValue("d",(*(self->model))(qx_value,qy_value));
453
454        } else {
455
456                // We have a scalar q, we will evaluate I(q)
457                qx_value = CBinaryHSPSF11Model_readDouble(pars);               
458               
459                return Py_BuildValue("d",(*(self->model))(qx_value));
460        }       
461}
462
463static PyObject * reset(CBinaryHSPSF11Model *self, PyObject *args) {
464   
465
466    return Py_BuildValue("d",0.0);
467}
468
469static PyObject * set_dispersion(CBinaryHSPSF11Model *self, PyObject *args) {
470        PyObject * disp;
471        const char * par_name;
472
473        if ( !PyArg_ParseTuple(args,"sO", &par_name, &disp) ) {
474            PyErr_SetString(CBinaryHSPSF11ModelError,
475                "CBinaryHSPSF11Model.set_dispersion expects a DispersionModel object.");
476                return NULL;
477        }
478        void *temp = PyCObject_AsVoidPtr(disp);
479        DispersionModel * dispersion = static_cast<DispersionModel *>(temp);
480
481
482        // Ugliness necessary to go from python to C
483            // TODO: refactor this
484    if (!strcmp(par_name, "l_radius")) {
485        self->model->l_radius.dispersion = dispersion;
486    } else    if (!strcmp(par_name, "s_radius")) {
487        self->model->s_radius.dispersion = dispersion;
488    } else {
489            PyErr_SetString(CBinaryHSPSF11ModelError,
490                "CBinaryHSPSF11Model.set_dispersion expects a valid parameter name.");
491                return NULL;
492        }
493
494        DispersionVisitor* visitor = new DispersionVisitor();
495        PyObject * disp_dict = PyDict_New();
496        dispersion->accept_as_source(visitor, dispersion, disp_dict);
497        PyDict_SetItemString(self->dispersion, par_name, disp_dict);
498    return Py_BuildValue("i",1);
499}
500
501
502static PyMethodDef CBinaryHSPSF11Model_methods[] = {
503    {"run",      (PyCFunction)run     , METH_VARARGS,
504      "Evaluate the model at a given Q or Q, phi"},
505    {"runXY",      (PyCFunction)runXY     , METH_VARARGS,
506      "Evaluate the model at a given Q or Qx, Qy"},
[5eb9154]507    {"calculate_ER",      (PyCFunction)calculate_ER     , METH_VARARGS,
508      "Evaluate the model at a given Q or Q, phi"},
[9bd69098]509     
510    {"evalDistribution",  (PyCFunction)evalDistribution , METH_VARARGS,
511      "Evaluate the model at a given Q or Qx, Qy vector "},
[2c4b289]512    {"reset",    (PyCFunction)reset   , METH_VARARGS,
513      "Reset pair correlation"},
514    {"set_dispersion",      (PyCFunction)set_dispersion     , METH_VARARGS,
515      "Set the dispersion model for a given parameter"},
516   {NULL}
517};
518
519static PyTypeObject CBinaryHSPSF11ModelType = {
520    PyObject_HEAD_INIT(NULL)
521    0,                         /*ob_size*/
522    "CBinaryHSPSF11Model",             /*tp_name*/
523    sizeof(CBinaryHSPSF11Model),             /*tp_basicsize*/
524    0,                         /*tp_itemsize*/
525    (destructor)CBinaryHSPSF11Model_dealloc, /*tp_dealloc*/
526    0,                         /*tp_print*/
527    0,                         /*tp_getattr*/
528    0,                         /*tp_setattr*/
529    0,                         /*tp_compare*/
530    0,                         /*tp_repr*/
531    0,                         /*tp_as_number*/
532    0,                         /*tp_as_sequence*/
533    0,                         /*tp_as_mapping*/
534    0,                         /*tp_hash */
535    0,                         /*tp_call*/
536    0,                         /*tp_str*/
537    0,                         /*tp_getattro*/
538    0,                         /*tp_setattro*/
539    0,                         /*tp_as_buffer*/
540    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
541    "CBinaryHSPSF11Model objects",           /* tp_doc */
542    0,                         /* tp_traverse */
543    0,                         /* tp_clear */
544    0,                         /* tp_richcompare */
545    0,                         /* tp_weaklistoffset */
546    0,                         /* tp_iter */
547    0,                         /* tp_iternext */
548    CBinaryHSPSF11Model_methods,             /* tp_methods */
549    CBinaryHSPSF11Model_members,             /* tp_members */
550    0,                         /* tp_getset */
551    0,                         /* tp_base */
552    0,                         /* tp_dict */
553    0,                         /* tp_descr_get */
554    0,                         /* tp_descr_set */
555    0,                         /* tp_dictoffset */
556    (initproc)CBinaryHSPSF11Model_init,      /* tp_init */
557    0,                         /* tp_alloc */
558    CBinaryHSPSF11Model_new,                 /* tp_new */
559};
560
561
[9bd69098]562//static PyMethodDef module_methods[] = {
563//    {NULL}
564//};
[2c4b289]565
566/**
567 * Function used to add the model class to a module
568 * @param module: module to add the class to
569 */ 
570void addCBinaryHSPSF11Model(PyObject *module) {
571        PyObject *d;
572       
573    if (PyType_Ready(&CBinaryHSPSF11ModelType) < 0)
574        return;
575
576    Py_INCREF(&CBinaryHSPSF11ModelType);
577    PyModule_AddObject(module, "CBinaryHSPSF11Model", (PyObject *)&CBinaryHSPSF11ModelType);
578   
579    d = PyModule_GetDict(module);
580    CBinaryHSPSF11ModelError = PyErr_NewException("CBinaryHSPSF11Model.error", NULL, NULL);
581    PyDict_SetItemString(d, "CBinaryHSPSF11ModelError", CBinaryHSPSF11ModelError);
582}
583
Note: See TracBrowser for help on using the repository browser.