Ignore:
Timestamp:
Oct 28, 2008 3:22:22 PM (16 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
92320e5
Parents:
89fef2c
Message:

added description to model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansmodels/src/sans/models/c_extensions/CEllipticalCylinderModel.c

    rae3ce4e r9316609  
    1 /** CEllipticalCylinderModel 
     1/** [PYTHONCLASS] 
    22 * 
    33 * C extension  
     
    2020 
    2121/// Error object for raised exceptions 
    22 static PyObject * CEllipticalCylinderModelError = NULL; 
     22static PyObject * [PYTHONCLASS]Error = NULL; 
    2323 
    2424 
     
    3232    /// Model parameters 
    3333        EllipticalCylinderParameters model_pars; 
    34 } CEllipticalCylinderModel; 
     34} [PYTHONCLASS]; 
    3535 
    3636 
    3737static void 
    38 CEllipticalCylinderModel_dealloc(CEllipticalCylinderModel* self) 
     38[PYTHONCLASS]_dealloc([PYTHONCLASS]* self) 
    3939{ 
    4040    self->ob_type->tp_free((PyObject*)self); 
     
    4444 
    4545static PyObject * 
    46 CEllipticalCylinderModel_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 
     46[PYTHONCLASS]_new(PyTypeObject *type, PyObject *args, PyObject *kwds) 
    4747{ 
    48     CEllipticalCylinderModel *self; 
     48    [PYTHONCLASS] *self; 
    4949     
    50     self = (CEllipticalCylinderModel *)type->tp_alloc(type, 0); 
     50    self = ([PYTHONCLASS] *)type->tp_alloc(type, 0); 
    5151    
    5252    return (PyObject *)self; 
     
    5454 
    5555static int 
    56 CEllipticalCylinderModel_init(CEllipticalCylinderModel *self, PyObject *args, PyObject *kwds) 
     56[PYTHONCLASS]_init([PYTHONCLASS] *self, PyObject *args, PyObject *kwds) 
    5757{ 
    5858    if (self != NULL) { 
     
    8282} 
    8383 
    84 static PyMemberDef CEllipticalCylinderModel_members[] = { 
    85     {"params", T_OBJECT, offsetof(CEllipticalCylinderModel, params), 0, 
     84static PyMemberDef [PYTHONCLASS]_members[] = { 
     85    {"params", T_OBJECT, offsetof([PYTHONCLASS], params), 0, 
    8686     "Parameters"}, 
    87     {"log", T_OBJECT, offsetof(CEllipticalCylinderModel, log), 0, 
     87    {"log", T_OBJECT, offsetof([PYTHONCLASS], log), 0, 
    8888     "Log"}, 
    8989    {NULL}  /* Sentinel */ 
     
    9494    @return double 
    9595*/ 
    96 double CEllipticalCylinderModel_readDouble(PyObject *p) { 
     96double [PYTHONCLASS]_readDouble(PyObject *p) { 
    9797    if (PyFloat_Check(p)==1) { 
    9898        return (double)(((PyFloatObject *)(p))->ob_fval); 
     
    112112 * @return: function value 
    113113 */ 
    114 static PyObject * run(CEllipticalCylinderModel *self, PyObject *args) { 
     114static PyObject * run([PYTHONCLASS] *self, PyObject *args) { 
    115115        double q_value, phi_value; 
    116116        PyObject* pars; 
     
    133133        // Get input and determine whether we have to supply a 1D or 2D return value. 
    134134        if ( !PyArg_ParseTuple(args,"O",&pars) ) { 
    135             PyErr_SetString(CEllipticalCylinderModelError,  
    136                 "CEllipticalCylinderModel.run expects a q value."); 
     135            PyErr_SetString([PYTHONCLASS]Error,  
     136                "[PYTHONCLASS].run expects a q value."); 
    137137                return NULL; 
    138138        } 
     
    144144            npars = PyList_GET_SIZE(pars);  
    145145            if(npars!=2) { 
    146                 PyErr_SetString(CEllipticalCylinderModelError,  
    147                         "CEllipticalCylinderModel.run expects a double or a list of dimension 2."); 
     146                PyErr_SetString([PYTHONCLASS]Error,  
     147                        "[PYTHONCLASS].run expects a double or a list of dimension 2."); 
    148148                return NULL; 
    149149            } 
    150150            // We have a vector q, get the q and phi values at which 
    151151            // to evaluate I(q,phi) 
    152             q_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 
    153             phi_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,1)); 
     152            q_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 
     153            phi_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 
    154154            // Skip zero 
    155155            if (q_value==0) { 
     
    161161 
    162162                // We have a scalar q, we will evaluate I(q) 
    163                 q_value = CEllipticalCylinderModel_readDouble(pars);             
     163                q_value = [PYTHONCLASS]_readDouble(pars);                
    164164                 
    165165                return Py_BuildValue("d",elliptical_cylinder_analytical_1D(&(self->model_pars),q_value)); 
     
    172172 * @return: function value 
    173173 */ 
    174 static PyObject * runXY(CEllipticalCylinderModel *self, PyObject *args) { 
     174static PyObject * runXY([PYTHONCLASS] *self, PyObject *args) { 
    175175        double qx_value, qy_value; 
    176176        PyObject* pars; 
     
    193193        // Get input and determine whether we have to supply a 1D or 2D return value. 
    194194        if ( !PyArg_ParseTuple(args,"O",&pars) ) { 
    195             PyErr_SetString(CEllipticalCylinderModelError,  
    196                 "CEllipticalCylinderModel.run expects a q value."); 
     195            PyErr_SetString([PYTHONCLASS]Error,  
     196                "[PYTHONCLASS].run expects a q value."); 
    197197                return NULL; 
    198198        } 
     
    204204            npars = PyList_GET_SIZE(pars);  
    205205            if(npars!=2) { 
    206                 PyErr_SetString(CEllipticalCylinderModelError,  
    207                         "CEllipticalCylinderModel.run expects a double or a list of dimension 2."); 
     206                PyErr_SetString([PYTHONCLASS]Error,  
     207                        "[PYTHONCLASS].run expects a double or a list of dimension 2."); 
    208208                return NULL; 
    209209            } 
    210210            // We have a vector q, get the qx and qy values at which 
    211211            // to evaluate I(qx,qy) 
    212             qx_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,0)); 
    213             qy_value = CEllipticalCylinderModel_readDouble(PyList_GET_ITEM(pars,1)); 
     212            qx_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,0)); 
     213            qy_value = [PYTHONCLASS]_readDouble(PyList_GET_ITEM(pars,1)); 
    214214                return Py_BuildValue("d",elliptical_cylinder_analytical_2DXY(&(self->model_pars),qx_value,qy_value)); 
    215215 
     
    217217 
    218218                // We have a scalar q, we will evaluate I(q) 
    219                 qx_value = CEllipticalCylinderModel_readDouble(pars);            
     219                qx_value = [PYTHONCLASS]_readDouble(pars);               
    220220                 
    221221                return Py_BuildValue("d",elliptical_cylinder_analytical_1D(&(self->model_pars),qx_value)); 
     
    223223} 
    224224 
    225 static PyObject * reset(CEllipticalCylinderModel *self, PyObject *args) { 
     225static PyObject * reset([PYTHONCLASS] *self, PyObject *args) { 
    226226     
    227227 
     
    230230 
    231231 
    232 static PyMethodDef CEllipticalCylinderModel_methods[] = { 
     232static PyMethodDef [PYTHONCLASS]_methods[] = { 
    233233    {"run",      (PyCFunction)run     , METH_VARARGS, 
    234234      "Evaluate the model at a given Q or Q, phi"}, 
     
    242242}; 
    243243 
    244 static PyTypeObject CEllipticalCylinderModelType = { 
     244static PyTypeObject [PYTHONCLASS]Type = { 
    245245    PyObject_HEAD_INIT(NULL) 
    246246    0,                         /*ob_size*/ 
    247     "CEllipticalCylinderModel",             /*tp_name*/ 
    248     sizeof(CEllipticalCylinderModel),             /*tp_basicsize*/ 
     247    "[PYTHONCLASS]",             /*tp_name*/ 
     248    sizeof([PYTHONCLASS]),             /*tp_basicsize*/ 
    249249    0,                         /*tp_itemsize*/ 
    250     (destructor)CEllipticalCylinderModel_dealloc, /*tp_dealloc*/ 
     250    (destructor)[PYTHONCLASS]_dealloc, /*tp_dealloc*/ 
    251251    0,                         /*tp_print*/ 
    252252    0,                         /*tp_getattr*/ 
     
    264264    0,                         /*tp_as_buffer*/ 
    265265    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ 
    266     "CEllipticalCylinderModel objects",           /* tp_doc */ 
     266    "[PYTHONCLASS] objects",           /* tp_doc */ 
    267267    0,                         /* tp_traverse */ 
    268268    0,                         /* tp_clear */ 
     
    271271    0,                         /* tp_iter */ 
    272272    0,                         /* tp_iternext */ 
    273     CEllipticalCylinderModel_methods,             /* tp_methods */ 
    274     CEllipticalCylinderModel_members,             /* tp_members */ 
     273    [PYTHONCLASS]_methods,             /* tp_methods */ 
     274    [PYTHONCLASS]_members,             /* tp_members */ 
    275275    0,                         /* tp_getset */ 
    276276    0,                         /* tp_base */ 
     
    279279    0,                         /* tp_descr_set */ 
    280280    0,                         /* tp_dictoffset */ 
    281     (initproc)CEllipticalCylinderModel_init,      /* tp_init */ 
     281    (initproc)[PYTHONCLASS]_init,      /* tp_init */ 
    282282    0,                         /* tp_alloc */ 
    283     CEllipticalCylinderModel_new,                 /* tp_new */ 
     283    [PYTHONCLASS]_new,                 /* tp_new */ 
    284284}; 
    285285 
     
    293293 * @param module: module to add the class to 
    294294 */  
    295 void addCEllipticalCylinderModel(PyObject *module) { 
     295void add[PYTHONCLASS](PyObject *module) { 
    296296        PyObject *d; 
    297297         
    298     if (PyType_Ready(&CEllipticalCylinderModelType) < 0) 
     298    if (PyType_Ready(&[PYTHONCLASS]Type) < 0) 
    299299        return; 
    300300 
    301     Py_INCREF(&CEllipticalCylinderModelType); 
    302     PyModule_AddObject(module, "CEllipticalCylinderModel", (PyObject *)&CEllipticalCylinderModelType); 
     301    Py_INCREF(&[PYTHONCLASS]Type); 
     302    PyModule_AddObject(module, "[PYTHONCLASS]", (PyObject *)&[PYTHONCLASS]Type); 
    303303     
    304304    d = PyModule_GetDict(module); 
    305     CEllipticalCylinderModelError = PyErr_NewException("CEllipticalCylinderModel.error", NULL, NULL); 
    306     PyDict_SetItemString(d, "CEllipticalCylinderModelError", CEllipticalCylinderModelError); 
    307 } 
    308  
     305    [PYTHONCLASS]Error = PyErr_NewException("[PYTHONCLASS].error", NULL, NULL); 
     306    PyDict_SetItemString(d, "[PYTHONCLASS]Error", [PYTHONCLASS]Error); 
     307} 
     308 
Note: See TracChangeset for help on using the changeset viewer.