source: sasview/sansmodels/src/sans/models/c_models/CBinaryHSPSF11Model.cpp @ 9ce41c6

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 9ce41c6 was 9ce41c6, checked in by Gervaise Alina <gervyh@…>, 15 years ago

wrote unittest for all model untested , haven' test critial point error handling

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