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