Mercurial > hg > audiodb
changeset 744:124ae047b968
Added python bindings for liszt (LIst SiZes and Timepoints of each database entry)
author | mas01mc |
---|---|
date | Thu, 11 Nov 2010 05:34:47 +0000 |
parents | 63a75a2b5fa6 |
children | 6dfde1f7a7eb |
files | bindings/python/pyadb.py bindings/python/pyadbmodule.c |
diffstat | 2 files changed, 35 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/bindings/python/pyadb.py Tue Nov 09 08:21:49 2010 +0000 +++ b/bindings/python/pyadb.py Thu Nov 11 05:34:47 2010 +0000 @@ -90,7 +90,7 @@ args["features"] = args["features"].reshape((args["features"].shape[0],1)) args["nVect"], args["nDim"] = args["features"].shape args["features"] = args["features"].flatten() - if(powerData != None): + if(self.hasPower and powerData != None): if (len(args["power"].shape) == 1) : args["power"] = args["power"].reshape((args["power"].shape[0],1)) args["power"] = args["power"].flatten()
--- a/bindings/python/pyadbmodule.c Tue Nov 09 08:21:49 2010 +0000 +++ b/bindings/python/pyadbmodule.c Thu Nov 11 05:34:47 2010 +0000 @@ -283,6 +283,38 @@ } +/* liszt - list strings, sizes, and time-points of all database entries + * + */ +PyObject* _pyadb_liszt(PyObject *self, PyObject *args) +{ + adb_t *current_db; + int ok,i; + PyObject * incoming = NULL; + PyObject * outgoing = NULL; + PyObject * newBits = NULL; + + ok = PyArg_ParseTuple(args, "O", &incoming); + + if (!ok) return 0; + current_db = (adb_t *)PyCObject_AsVoidPtr(incoming); + + adb_liszt_results_t *liszt = audiodb_liszt(current_db); + + outgoing = PyList_New((Py_ssize_t)0); + for (i=0 ; i<liszt->nresults ; i++){ + newBits = Py_BuildValue("sI",liszt->entries[i].key,liszt->entries[i].nvectors); + if (PyList_Append(outgoing, newBits)){ + //error msg here + Py_XDECREF(newBits); + return NULL; + } + Py_DECREF(newBits); + } + audiodb_liszt_free_results(current_db, liszt); + return outgoing; +} + /* base query. The nomenclature here is about a far away as pythonic as is possible. * This should be taken care of via the higher level python structure * returns a dict that should be result ordered and key = result key @@ -581,6 +613,8 @@ { "_pyadb_insertFromFile", (PyCFunction)_pyadb_insertFromFile, METH_VARARGS | METH_KEYWORDS, "_pyadb_insertFromFile(adb_t *, features=featureFile, [power=powerfile | key=keystring | times=timingFile])->\ int return code (0 for sucess)"}, + { "_pyadb_liszt", (PyCFunction)_pyadb_liszt, METH_VARARGS, + "_pyadb_liszt(adb_t*)->[[key1,numvecs1],[key2,numvecs2]...]"}, { "_pyadb_queryFromKey", (PyCFunction)_pyadb_queryFromKey, METH_VARARGS | METH_KEYWORDS, "base query. The nomenclature here is about a far away as pythonic as is possible.\n\ This should be taken care of via the higher level python structure\n\