Skip to content
Snippets Groups Projects
Commit 39ec133e authored by Olivier Stasse's avatar Olivier Stasse
Browse files

Makes eigenpy compliant with NUMPY 1.8 (on Ubuntu 14.04 LTS)

parent d43c336c
No related branches found
No related tags found
No related merge requests found
......@@ -137,11 +137,12 @@ namespace eigenpy
EigenFromPy()
{
bp::converter::registry::push_back
(&convertible,&construct,bp::type_id<MatType>());
(reinterpret_cast<void *(*)(_object *)>(&convertible),
&construct,bp::type_id<MatType>());
}
// 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 +163,18 @@ namespace eigenpy
return 0;
}
if ((PyArray_ObjectType(obj_ptr, 0)) != NumpyEquivalentType<T>::type_code)
if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(obj_ptr), 0)) != NumpyEquivalentType<T>::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;
......
......@@ -19,6 +19,7 @@
#include <boost/python.hpp>
#include <Eigen/Core>
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
namespace eigenpy
{
......
......@@ -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) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment