comparison PyTypeInterface.h @ 66:5664fe298af2

Update to Python 2.7 and clean up the build (avoid using deprecated NumPy API, fix compiler warnings)
author Chris Cannam
date Mon, 17 Nov 2014 09:37:59 +0000
parents 74703a562ce3
children 40a01bb24209 5e26aaba2eed
comparison
equal deleted inserted replaced
65:0df94e3f0fdb 66:5664fe298af2
1 /* -*- c-basic-offset: 8 indent-tabs-mode: t -*- */
1 /* 2 /*
2 3
3 * Vampy : This plugin is a wrapper around the Vamp plugin API. 4 * Vampy : This plugin is a wrapper around the Vamp plugin API.
4 * It allows for writing Vamp plugins in Python. 5 * It allows for writing Vamp plugins in Python.
5 6
18 #define _PY_TYPE_INTERFACE_H_ 19 #define _PY_TYPE_INTERFACE_H_
19 #include <Python.h> 20 #include <Python.h>
20 #ifdef HAVE_NUMPY 21 #ifdef HAVE_NUMPY
21 #define PY_ARRAY_UNIQUE_SYMBOL VAMPY_ARRAY_API 22 #define PY_ARRAY_UNIQUE_SYMBOL VAMPY_ARRAY_API
22 #define NO_IMPORT_ARRAY 23 #define NO_IMPORT_ARRAY
24 #define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
23 #include "numpy/arrayobject.h" 25 #include "numpy/arrayobject.h"
24 #endif 26 #endif
25 #include "PyExtensionModule.h" 27 #include "PyExtensionModule.h"
26 #include <vector> 28 #include <vector>
27 #include <queue> 29 #include <queue>
294 296
295 } 297 }
296 298
297 /// Convert DTYPE type 1D NumpyArray to std::vector<RET> 299 /// Convert DTYPE type 1D NumpyArray to std::vector<RET>
298 template<typename RET, typename DTYPE> 300 template<typename RET, typename DTYPE>
299 std::vector<RET> PyArray_Convert(char* raw_data_ptr, long length, size_t strides) const 301 std::vector<RET> PyArray_Convert(void* raw_data_ptr, long length, size_t strides) const
300 { 302 {
301 std::vector<RET> rValue; 303 std::vector<RET> rValue;
302 304
303 /// check if the array is continuous, if not use strides info 305 /// check if the array is continuous, if not use strides info
304 if (sizeof(DTYPE)!=strides) { 306 if (sizeof(DTYPE)!=strides) {
575 577
576 for (size_t i=0; i < channels; ++i) { 578 for (size_t i=0; i < channels; ++i) {
577 PyObject *pyChannelArray = 579 PyObject *pyChannelArray =
578 //args: (dimensions, size in each dim, type kind, pointer to continuous array) 580 //args: (dimensions, size in each dim, type kind, pointer to continuous array)
579 PyArray_SimpleNewFromData(1, ndims, typenum, (void*) inputBuffers[i]); 581 PyArray_SimpleNewFromData(1, ndims, typenum, (void*) inputBuffers[i]);
580 // make it read-only: set all flags to false except NPY_C_CONTIGUOUS 582 // make it read-only: set all flags to false except NPY_C_CONTIGUOUS
581 ((PyArrayObject*)pyChannelArray)->flags = NPY_C_CONTIGUOUS; 583 //!!! what about NPY_ARRAY_OWNDATA?
584 PyArray_CLEARFLAGS((PyArrayObject *)pyChannelArray, 0xff);
585 PyArray_ENABLEFLAGS((PyArrayObject *)pyChannelArray, NPY_ARRAY_C_CONTIGUOUS);
582 pyChannelListArray[i] = pyChannelArray; 586 pyChannelListArray[i] = pyChannelArray;
583 } 587 }
584 return pyChannelList; 588 return pyChannelList;
585 } 589 }
586 #endif 590 #endif