ref: 1458de5218ce62307074b6a973aa1104f9e7e990
parent: c71e40548aa64b7dc3203fa7fa4d00c7047cc24e
author: Paul Brossier <piem@piem.org>
date: Tue Jul 10 15:41:33 EDT 2012
aubio-types.h, aubiomodule.c: update for numpy 1.8
--- a/interfaces/python/aubio-types.h
+++ b/interfaces/python/aubio-types.h
@@ -1,6 +1,7 @@
#include <Python.h>
#include <structmember.h>
#define NO_IMPORT_ARRAY
+#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <numpy/arrayobject.h>
#define AUBIO_UNSTABLE 1
#include <aubio.h>
--- a/interfaces/python/aubiomodule.c
+++ b/interfaces/python/aubiomodule.c
@@ -1,5 +1,6 @@
#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"
@@ -131,17 +132,17 @@
return;
}
+ m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc);
+
+ if (m == NULL) {
+ return;
+ }
+
err = _import_array ();
if (err != 0) {
fprintf (stderr,
"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);
--- a/interfaces/python/aubioproxy.c
+++ b/interfaces/python/aubioproxy.c
@@ -12,19 +12,19 @@
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 {
@@ -35,8 +35,8 @@
// 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");
--- a/interfaces/python/py-cvec.c
+++ b/interfaces/python/py-cvec.c
@@ -125,7 +125,7 @@
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;
@@ -133,23 +133,23 @@
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) {
@@ -161,7 +161,7 @@
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;
}
}
@@ -183,7 +183,7 @@
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;
@@ -191,23 +191,23 @@
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) {
@@ -219,7 +219,7 @@
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;
}
}