ref: 84e0606b011337625ca664ea1a26162a884b6009
parent: 3e882a8e7e4ee36e05aafe96090a5599658ec19a
author: Paul Brossier <piem@piem.org>
date: Thu Dec 24 23:56:48 EST 2009
py-cvec.c: remove obsolete proxy functions
--- a/interfaces/python/aubio-types.h
+++ b/interfaces/python/aubio-types.h
@@ -26,8 +26,6 @@
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);
--- a/interfaces/python/py-cvec.c
+++ b/interfaces/python/py-cvec.c
@@ -89,88 +89,7 @@
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)
{
npy_intp dims[] = { self->o->length, 1 };
@@ -327,8 +246,6 @@
};
static PyMethodDef Py_cvec_methods[] = {
- {"__array__", (PyCFunction) PyAubio_CvecToArray, METH_NOARGS,
- "Returns the content of this cvec as a numpy array"},
{NULL}
};