Skip to content

Commit 39ec133

Browse files
Makes eigenpy compliant with NUMPY 1.8 (on Ubuntu 14.04 LTS)
1 parent d43c336 commit 39ec133

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

src/details.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,12 @@ namespace eigenpy
137137
EigenFromPy()
138138
{
139139
bp::converter::registry::push_back
140-
(&convertible,&construct,bp::type_id<MatType>());
140+
(reinterpret_cast<void *(*)(_object *)>(&convertible),
141+
&construct,bp::type_id<MatType>());
141142
}
142143

143144
// Determine if obj_ptr can be converted in a Eigenvec
144-
static void* convertible(PyObject* obj_ptr)
145+
static void* convertible(PyArrayObject* obj_ptr)
145146
{
146147
typedef typename MatType::Scalar T;
147148

@@ -162,15 +163,18 @@ namespace eigenpy
162163
return 0;
163164
}
164165

165-
if ((PyArray_ObjectType(obj_ptr, 0)) != NumpyEquivalentType<T>::type_code)
166+
if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(obj_ptr), 0)) != NumpyEquivalentType<T>::type_code)
166167
{
167168
#ifndef NDEBUG
168169
std::cerr << "The internal type as no Eigen equivalent." << std::endl;
169170
#endif
170171
return 0;
171172
}
172-
173+
#ifdef NPY_1_8_API_VERSION
174+
if (!(PyArray_FLAGS(obj_ptr)))
175+
#else
173176
if (!(PyArray_FLAGS(obj_ptr) & NPY_ALIGNED))
177+
#endif
174178
{
175179
#ifndef NDEBUG
176180
std::cerr << "NPY non-aligned matrices are not implemented." << std::endl;

src/fwd.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <boost/python.hpp>
2121
#include <Eigen/Core>
22+
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
2223

2324
namespace eigenpy
2425
{

src/map.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ namespace eigenpy
6060

6161
const int R = (int)PyArray_DIMS(pyArray)[0];
6262
const int C = (int)PyArray_DIMS(pyArray)[1];
63-
const int itemsize = PyArray_ITEMSIZE(pyArray);
64-
const int stride1 = (int)PyArray_STRIDE(pyArray, 0) / itemsize;
65-
const int stride2 = (int)PyArray_STRIDE(pyArray, 1) / itemsize;
63+
const long int itemsize = PyArray_ITEMSIZE(pyArray);
64+
const int stride1 = (int)PyArray_STRIDE(pyArray, 0) / (int)itemsize;
65+
const int stride2 = (int)PyArray_STRIDE(pyArray, 1) / (int)itemsize;
6666

6767
if( (MatType::RowsAtCompileTime!=R)
6868
&& (MatType::RowsAtCompileTime!=Eigen::Dynamic) )
@@ -94,8 +94,8 @@ namespace eigenpy
9494
assert( (PyArray_DIMS(pyArray)[rowMajor]< INT_MAX)
9595
&& (PyArray_STRIDE(pyArray, rowMajor) ));
9696
const int R = (int)PyArray_DIMS(pyArray)[rowMajor];
97-
const int itemsize = PyArray_ITEMSIZE(pyArray);
98-
const int stride = (int) PyArray_STRIDE(pyArray, rowMajor) / itemsize;;
97+
const long int itemsize = PyArray_ITEMSIZE(pyArray);
98+
const int stride = (int) PyArray_STRIDE(pyArray, rowMajor) / (int) itemsize;;
9999

100100
if( (MatType::MaxSizeAtCompileTime!=R)
101101
&& (MatType::MaxSizeAtCompileTime!=Eigen::Dynamic) )

0 commit comments

Comments
 (0)