diff --git a/src/details.hpp b/src/details.hpp index 5a69885b4..949ed0c21 100644 --- a/src/details.hpp +++ b/src/details.hpp @@ -20,6 +20,11 @@ #include #include +#include +#ifdef NPY_1_8_API_VERSION +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#endif + #include #include @@ -137,11 +142,12 @@ namespace eigenpy EigenFromPy() { bp::converter::registry::push_back - (&convertible,&construct,bp::type_id()); + (reinterpret_cast(&convertible), + &construct,bp::type_id()); } // Determine if obj_ptr can be converted in a Eigenvec - static void* convertible(PyObject* obj_ptr) + static void* convertible(PyArrayObject* obj_ptr) { typedef typename MatType::Scalar T; @@ -162,15 +168,18 @@ namespace eigenpy return 0; } - if ((PyArray_ObjectType(obj_ptr, 0)) != NumpyEquivalentType::type_code) + if ((PyArray_ObjectType(reinterpret_cast(obj_ptr), 0)) != NumpyEquivalentType::type_code) { #ifndef NDEBUG std::cerr << "The internal type as no Eigen equivalent." << std::endl; #endif return 0; } - +#ifdef NPY_1_8_API_VERSION + if (!(PyArray_FLAGS(obj_ptr))) +#else if (!(PyArray_FLAGS(obj_ptr) & NPY_ALIGNED)) +#endif { #ifndef NDEBUG std::cerr << "NPY non-aligned matrices are not implemented." << std::endl; diff --git a/src/fwd.hpp b/src/fwd.hpp index 1fe3dd1d4..378046ed5 100644 --- a/src/fwd.hpp +++ b/src/fwd.hpp @@ -20,6 +20,10 @@ #include #include +#ifdef NPY_1_8_API_VERSION +#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION +#endif + namespace eigenpy { template diff --git a/src/map.hpp b/src/map.hpp index 6d574949f..0c0b633d4 100644 --- a/src/map.hpp +++ b/src/map.hpp @@ -60,9 +60,9 @@ namespace eigenpy const int R = (int)PyArray_DIMS(pyArray)[0]; const int C = (int)PyArray_DIMS(pyArray)[1]; - const int itemsize = PyArray_ITEMSIZE(pyArray); - const int stride1 = (int)PyArray_STRIDE(pyArray, 0) / itemsize; - const int stride2 = (int)PyArray_STRIDE(pyArray, 1) / itemsize; + const long int itemsize = PyArray_ITEMSIZE(pyArray); + const int stride1 = (int)PyArray_STRIDE(pyArray, 0) / (int)itemsize; + const int stride2 = (int)PyArray_STRIDE(pyArray, 1) / (int)itemsize; if( (MatType::RowsAtCompileTime!=R) && (MatType::RowsAtCompileTime!=Eigen::Dynamic) ) @@ -94,8 +94,8 @@ namespace eigenpy assert( (PyArray_DIMS(pyArray)[rowMajor]< INT_MAX) && (PyArray_STRIDE(pyArray, rowMajor) )); const int R = (int)PyArray_DIMS(pyArray)[rowMajor]; - const int itemsize = PyArray_ITEMSIZE(pyArray); - const int stride = (int) PyArray_STRIDE(pyArray, rowMajor) / itemsize;; + const long int itemsize = PyArray_ITEMSIZE(pyArray); + const int stride = (int) PyArray_STRIDE(pyArray, rowMajor) / (int) itemsize;; if( (MatType::MaxSizeAtCompileTime!=R) && (MatType::MaxSizeAtCompileTime!=Eigen::Dynamic) )