From 84e0606b011337625ca664ea1a26162a884b6009 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 25 Dec 2009 04:56:48 +0100 Subject: [PATCH] py-cvec.c: remove obsolete proxy functions --- interfaces/python/aubio-types.h | 2 - interfaces/python/py-cvec.c | 83 --------------------------------- 2 files changed, 85 deletions(-) diff --git a/interfaces/python/aubio-types.h b/interfaces/python/aubio-types.h index c1fd56d2..236e3a75 100644 --- a/interfaces/python/aubio-types.h +++ b/interfaces/python/aubio-types.h @@ -26,8 +26,6 @@ typedef struct uint_t channels; } Py_cvec; extern PyTypeObject Py_cvecType; -extern PyObject *PyAubio_CvecToArray (Py_cvec * self); -extern Py_cvec *PyAubio_ArrayToCvec (PyObject * self); // defined in aubio-proxy.c extern PyObject *PyAubio_CFvecToArray (fvec_t * self); diff --git a/interfaces/python/py-cvec.c b/interfaces/python/py-cvec.c index 9290e7c1..387e671e 100644 --- a/interfaces/python/py-cvec.c +++ b/interfaces/python/py-cvec.c @@ -89,87 +89,6 @@ fail: return result; } -Py_cvec * -PyAubio_ArrayToCvec (PyObject *input) { - PyObject *array; - Py_cvec *vec; - if (input == NULL) { - PyErr_SetString (PyExc_ValueError, "input array is not a python object"); - goto fail; - } - // parsing input object into a Py_cvec - if (PyObject_TypeCheck (input, &Py_cvecType)) { - // input is an cvec, nothing else to do - vec = (Py_cvec *) input; - } else if (PyArray_Check(input)) { - - // we got an array, convert it to an cvec - if (PyArray_NDIM (input) == 0) { - PyErr_SetString (PyExc_ValueError, "input array is a scalar"); - goto fail; - } else if (PyArray_NDIM (input) > 1) { - PyErr_SetString (PyExc_ValueError, - "input array has more than one dimensions"); - goto fail; - } - - if (!PyArray_ISFLOAT (input)) { - PyErr_SetString (PyExc_ValueError, "input array should be float"); - goto fail; - } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) { - PyErr_SetString (PyExc_ValueError, "input array should be float32"); - goto fail; - } else { - // input data type is float32, nothing else to do - array = input; - } - - // create a new cvec object - vec = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType); - if (PyArray_NDIM (array) != 2) { - PyErr_SetString (PyExc_ValueError, - "input array should be have exactly two rows for norm and phas"); - goto fail; - } else { - vec->length = PyArray_SIZE (array); - } - - // no need to really allocate cvec, just its struct member - // vec->o = new_cvec (vec->length); - vec->o = (cvec_t *)malloc(sizeof(cvec_t)); - vec->o->length = vec->length; - // have norm and phas point to array rows - vec->o->norm = (smpl_t *) PyArray_GETPTR1 (array, 0); - vec->o->phas = (smpl_t *) PyArray_GETPTR1 (array, 1); - - } else { - PyErr_SetString (PyExc_ValueError, "can only accept array or cvec as input"); - return NULL; - } - - return vec; - -fail: - return NULL; -} - -PyObject * -PyAubio_CvecToArray (Py_cvec * self) -{ - PyObject *array = NULL; - npy_intp dims[] = { self->o->length, 1 }; - PyObject *concat = PyList_New (0), *tmp = NULL; - tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->norm); - PyList_Append (concat, tmp); - Py_DECREF (tmp); - tmp = PyArray_SimpleNewFromData (1, dims, NPY_FLOAT, self->o->phas); - PyList_Append (concat, tmp); - Py_DECREF (tmp); - array = PyArray_FromObject (concat, NPY_FLOAT, 2, 2); - Py_DECREF (concat); - return array; -} - PyObject * PyAubio_CvecNormToArray (Py_cvec * self) { @@ -327,8 +246,6 @@ static PyMemberDef Py_cvec_members[] = { }; static PyMethodDef Py_cvec_methods[] = { - {"__array__", (PyCFunction) PyAubio_CvecToArray, METH_NOARGS, - "Returns the content of this cvec as a numpy array"}, {NULL} }; -- 2.26.2