#include <Python.h>
#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <numpy/arrayobject.h>
#include "aubio-types.h"
return;
}
+ m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc);
+
+ if (m == NULL) {
+ return;
+ }
+
err = _import_array ();
if (err != 0) {
"Unable to import Numpy C API from aubio module (error %d)\n", err);
}
- m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc);
-
- if (m == NULL) {
- return;
- }
-
Py_INCREF (&Py_cvecType);
PyModule_AddObject (m, "cvec", (PyObject *) & Py_cvecType);
Py_INCREF (&Py_filterType);
if (PyArray_Check(input)) {
// we got an array, convert it to an fvec
- if (PyArray_NDIM (input) == 0) {
+ if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
PyErr_SetString (PyExc_ValueError, "input array is a scalar");
goto fail;
- } else if (PyArray_NDIM (input) > 1) {
+ } else if (PyArray_NDIM ((PyArrayObject *)input) > 1) {
PyErr_SetString (PyExc_ValueError,
"input array has more than one dimensions");
goto fail;
}
- if (!PyArray_ISFLOAT (input)) {
+ if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
PyErr_SetString (PyExc_ValueError, "input array should be float");
goto fail;
- } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
+ } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
PyErr_SetString (PyExc_ValueError, "input array should be float32");
goto fail;
} else {
// vec = new_fvec (vec->length);
// no need to really allocate fvec, just its struct member
vec = (fvec_t *)malloc(sizeof(fvec_t));
- vec->length = PyArray_SIZE (array);
- vec->data = (smpl_t *) PyArray_GETPTR1 (array, 0);
+ vec->length = PyArray_SIZE ((PyArrayObject *)array);
+ vec->data = (smpl_t *) PyArray_GETPTR1 ((PyArrayObject *)array, 0);
} else if (PyObject_TypeCheck (input, &PyList_Type)) {
PyErr_SetString (PyExc_ValueError, "does not convert from list yet");
static int
Py_cvec_set_norm (Py_cvec * vec, PyObject *input, void * closure)
{
- PyObject * array;
+ PyArrayObject * array;
if (input == NULL) {
PyErr_SetString (PyExc_ValueError, "input array is not a python object");
goto fail;
if (PyArray_Check(input)) {
// we got an array, convert it to a cvec.norm
- if (PyArray_NDIM (input) == 0) {
+ if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
PyErr_SetString (PyExc_ValueError, "input array is a scalar");
goto fail;
- } else if (PyArray_NDIM (input) > 2) {
+ } else if (PyArray_NDIM ((PyArrayObject *)input) > 2) {
PyErr_SetString (PyExc_ValueError,
"input array has more than two dimensions");
goto fail;
}
- if (!PyArray_ISFLOAT (input)) {
+ if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
PyErr_SetString (PyExc_ValueError, "input array should be float");
goto fail;
- } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
+ } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
PyErr_SetString (PyExc_ValueError, "input array should be float32");
goto fail;
}
- array = input;
+ array = (PyArrayObject *)input;
// check input array dimensions
if (PyArray_NDIM (array) != 1) {
if (vec->o->length != PyArray_SIZE (array)) {
PyErr_Format (PyExc_ValueError,
"input array has length %d, but cvec has length %d",
- PyArray_SIZE (array), vec->o->length);
+ (int)PyArray_SIZE (array), vec->o->length);
goto fail;
}
}
static int
Py_cvec_set_phas (Py_cvec * vec, PyObject *input, void * closure)
{
- PyObject * array;
+ PyArrayObject * array;
if (input == NULL) {
PyErr_SetString (PyExc_ValueError, "input array is not a python object");
goto fail;
if (PyArray_Check(input)) {
// we got an array, convert it to a cvec.phas
- if (PyArray_NDIM (input) == 0) {
+ if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
PyErr_SetString (PyExc_ValueError, "input array is a scalar");
goto fail;
- } else if (PyArray_NDIM (input) > 2) {
+ } else if (PyArray_NDIM ((PyArrayObject *)input) > 2) {
PyErr_SetString (PyExc_ValueError,
"input array has more than two dimensions");
goto fail;
}
- if (!PyArray_ISFLOAT (input)) {
+ if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
PyErr_SetString (PyExc_ValueError, "input array should be float");
goto fail;
- } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
+ } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
PyErr_SetString (PyExc_ValueError, "input array should be float32");
goto fail;
}
- array = input;
+ array = (PyArrayObject *)input;
// check input array dimensions
if (PyArray_NDIM (array) != 1) {
if (vec->o->length != PyArray_SIZE (array)) {
PyErr_Format (PyExc_ValueError,
"input array has length %d, but cvec has length %d",
- PyArray_SIZE (array), vec->o->length);
+ (int)PyArray_SIZE (array), vec->o->length);
goto fail;
}
}