Changeset 1458de5


Ignore:
Timestamp:
Jul 11, 2012, 3:41:33 AM (12 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
988f580
Parents:
c71e405
Message:

aubio-types.h, aubiomodule.c: update for numpy 1.8

Location:
interfaces/python
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • interfaces/python/aubio-types.h

    rc71e405 r1458de5  
    22#include <structmember.h>
    33#define NO_IMPORT_ARRAY
     4#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
    45#include <numpy/arrayobject.h>
    56#define AUBIO_UNSTABLE 1
  • interfaces/python/aubiomodule.c

    rc71e405 r1458de5  
    11#include <Python.h>
    22#define PY_ARRAY_UNIQUE_SYMBOL PyArray_API
     3#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
    34#include <numpy/arrayobject.h>
    45
     
    132133  }
    133134
     135  m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc);
     136
     137  if (m == NULL) {
     138    return;
     139  }
     140
    134141  err = _import_array ();
    135142
     
    137144    fprintf (stderr,
    138145        "Unable to import Numpy C API from aubio module (error %d)\n", err);
    139   }
    140 
    141   m = Py_InitModule3 ("_aubio", aubio_methods, aubio_module_doc);
    142 
    143   if (m == NULL) {
    144     return;
    145146  }
    146147
  • interfaces/python/aubioproxy.c

    rc71e405 r1458de5  
    1313
    1414    // we got an array, convert it to an fvec
    15     if (PyArray_NDIM (input) == 0) {
     15    if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
    1616      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
    1717      goto fail;
    18     } else if (PyArray_NDIM (input) > 1) {
     18    } else if (PyArray_NDIM ((PyArrayObject *)input) > 1) {
    1919      PyErr_SetString (PyExc_ValueError,
    2020          "input array has more than one dimensions");
     
    2222    }
    2323
    24     if (!PyArray_ISFLOAT (input)) {
     24    if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
    2525      PyErr_SetString (PyExc_ValueError, "input array should be float");
    2626      goto fail;
    27     } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
     27    } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
    2828      PyErr_SetString (PyExc_ValueError, "input array should be float32");
    2929      goto fail;
     
    3636    // no need to really allocate fvec, just its struct member
    3737    vec = (fvec_t *)malloc(sizeof(fvec_t));
    38     vec->length = PyArray_SIZE (array);
    39     vec->data = (smpl_t *) PyArray_GETPTR1 (array, 0);
     38    vec->length = PyArray_SIZE ((PyArrayObject *)array);
     39    vec->data = (smpl_t *) PyArray_GETPTR1 ((PyArrayObject *)array, 0);
    4040
    4141  } else if (PyObject_TypeCheck (input, &PyList_Type)) {
  • interfaces/python/py-cvec.c

    rc71e405 r1458de5  
    126126Py_cvec_set_norm (Py_cvec * vec, PyObject *input, void * closure)
    127127{
    128   PyObject * array;
     128  PyArrayObject * array;
    129129  if (input == NULL) {
    130130    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
     
    134134
    135135    // we got an array, convert it to a cvec.norm
    136     if (PyArray_NDIM (input) == 0) {
     136    if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
    137137      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
    138138      goto fail;
    139     } else if (PyArray_NDIM (input) > 2) {
     139    } else if (PyArray_NDIM ((PyArrayObject *)input) > 2) {
    140140      PyErr_SetString (PyExc_ValueError,
    141141          "input array has more than two dimensions");
     
    143143    }
    144144
    145     if (!PyArray_ISFLOAT (input)) {
     145    if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
    146146      PyErr_SetString (PyExc_ValueError, "input array should be float");
    147147      goto fail;
    148     } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
     148    } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
    149149      PyErr_SetString (PyExc_ValueError, "input array should be float32");
    150150      goto fail;
    151151    }
    152     array = input;
     152    array = (PyArrayObject *)input;
    153153
    154154    // check input array dimensions
     
    162162          PyErr_Format (PyExc_ValueError,
    163163                  "input array has length %d, but cvec has length %d",
    164                   PyArray_SIZE (array), vec->o->length);
     164                  (int)PyArray_SIZE (array), vec->o->length);
    165165          goto fail;
    166166      }
     
    184184Py_cvec_set_phas (Py_cvec * vec, PyObject *input, void * closure)
    185185{
    186   PyObject * array;
     186  PyArrayObject * array;
    187187  if (input == NULL) {
    188188    PyErr_SetString (PyExc_ValueError, "input array is not a python object");
     
    192192
    193193    // we got an array, convert it to a cvec.phas
    194     if (PyArray_NDIM (input) == 0) {
     194    if (PyArray_NDIM ((PyArrayObject *)input) == 0) {
    195195      PyErr_SetString (PyExc_ValueError, "input array is a scalar");
    196196      goto fail;
    197     } else if (PyArray_NDIM (input) > 2) {
     197    } else if (PyArray_NDIM ((PyArrayObject *)input) > 2) {
    198198      PyErr_SetString (PyExc_ValueError,
    199199          "input array has more than two dimensions");
     
    201201    }
    202202
    203     if (!PyArray_ISFLOAT (input)) {
     203    if (!PyArray_ISFLOAT ((PyArrayObject *)input)) {
    204204      PyErr_SetString (PyExc_ValueError, "input array should be float");
    205205      goto fail;
    206     } else if (PyArray_TYPE (input) != AUBIO_NPY_SMPL) {
     206    } else if (PyArray_TYPE ((PyArrayObject *)input) != AUBIO_NPY_SMPL) {
    207207      PyErr_SetString (PyExc_ValueError, "input array should be float32");
    208208      goto fail;
    209209    }
    210     array = input;
     210    array = (PyArrayObject *)input;
    211211
    212212    // check input array dimensions
     
    220220          PyErr_Format (PyExc_ValueError,
    221221                  "input array has length %d, but cvec has length %d",
    222                   PyArray_SIZE (array), vec->o->length);
     222                  (int)PyArray_SIZE (array), vec->o->length);
    223223          goto fail;
    224224      }
Note: See TracChangeset for help on using the changeset viewer.