comparison bindings/python/pyadbmodule.c @ 743:63a75a2b5fa6

Added insert featureData and powerData from numpy ndarray pathway
author mas01mc
date Tue, 09 Nov 2010 08:21:49 +0000
parents 2fad8cfdb2d8
children 124ae047b968
comparison
equal deleted inserted replaced
739:040f14b5a5fc 743:63a75a2b5fa6
158 const char *key = NULL; 158 const char *key = NULL;
159 PyArray_Descr *descr; 159 PyArray_Descr *descr;
160 static char *kwlist[] = { "db", "features", "nDim", "nVect", "power", "key", "times" , NULL}; 160 static char *kwlist[] = { "db", "features", "nDim", "nVect", "power", "key", "times" , NULL};
161 161
162 ok = PyArg_ParseTupleAndKeywords(args, keywds, "OO!II|O!sO!", kwlist, &incoming, &PyArray_Type, &features, &nDims, &nVect, &PyArray_Type, &power, &key, &PyArray_Type, &times); 162 ok = PyArg_ParseTupleAndKeywords(args, keywds, "OO!II|O!sO!", kwlist, &incoming, &PyArray_Type, &features, &nDims, &nVect, &PyArray_Type, &power, &key, &PyArray_Type, &times);
163 if (!ok){return NULL;} 163 if (!ok){
164 PyErr_SetString(PyExc_TypeError, "Failed at PyArg_ParseTupleAndKeywords");
165 return NULL;
166 }
164 //check our arrays 167 //check our arrays
165 // if (!PyArray_Check(features)){ 168 // if (!PyArray_Check(features)){
166 // PyErr_SetString(PyExc_TypeError, "features must be a numpy array (of floats or doubles)"); 169 // PyErr_SetString(PyExc_TypeError, "features must be a numpy array (of floats or doubles)");
167 // return NULL; 170 // return NULL;
168 // } 171 // }
184 if (!PyArray_ISFLOAT(power)){ 187 if (!PyArray_ISFLOAT(power)){
185 PyErr_SetString(PyExc_TypeError, "power numpy array, if given, must contain floats or doubles"); 188 PyErr_SetString(PyExc_TypeError, "power numpy array, if given, must contain floats or doubles");
186 return NULL; 189 return NULL;
187 } 190 }
188 // power = (PyArrayObject *)PyCObject_AsVoidPtr(incomingPow); 191 // power = (PyArrayObject *)PyCObject_AsVoidPtr(incomingPow);
189 if (PyArray_NDIM(features) != 1 || PyArray_DIMS(power)[0] == nVect){ 192 if (PyArray_NDIM(features) != 1 || PyArray_DIMS(power)[0] != nVect){
190 PyErr_SetString(PyExc_ValueError, "power, if given must be a 1d numpy array with shape = (numVectors,)"); 193 PyErr_SetString(PyExc_ValueError, "power, if given must be a 1d numpy array with shape = (numVectors,)");
191 return NULL; 194 return NULL;
192 } 195 }
193 } 196 }
194 if (times){ 197 if (times){