Skip to content

Commit b2eca85

Browse files
committed
core: fix call to PyArray_Check
1 parent 4e82e8b commit b2eca85

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

include/eigenpy/eigen-from-python.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ namespace eigenpy
285285
template<typename MatType>
286286
void* EigenFromPy<MatType>::convertible(PyArrayObject* pyArray)
287287
{
288-
if(!PyArray_Check(pyArray))
288+
if(!call_PyArray_Check(pyArray))
289289
return 0;
290290

291291
if(!np_type_is_convertible_into_scalar<Scalar>(EIGENPY_GET_PY_ARRAY_TYPE(pyArray)))
@@ -476,7 +476,7 @@ namespace eigenpy
476476
/// \brief Determine if pyObj can be converted into a MatType object
477477
static void* convertible(PyArrayObject * pyArray)
478478
{
479-
if(!PyArray_Check(pyArray))
479+
if(!call_PyArray_Check(pyArray))
480480
return 0;
481481
if(!PyArray_ISWRITEABLE(pyArray))
482482
return 0;

include/eigenpy/numpy.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ namespace eigenpy
3737
#if defined _WIN32 || defined __CYGWIN__
3838
namespace eigenpy
3939
{
40+
EIGENPY_DLLEXPORT bool call_PyArray_Check(PyObject *);
41+
4042
EIGENPY_DLLEXPORT PyObject* call_PyArray_SimpleNew(int nd, npy_intp * shape, int np_type);
4143

4244
EIGENPY_DLLEXPORT PyObject* call_PyArray_New(PyTypeObject * py_type_ptr, int nd, npy_intp * shape, int np_type, void * data_ptr, int options);
@@ -52,6 +54,7 @@ namespace eigenpy
5254
EIGENPY_DLLEXPORT int call_PyArray_RegisterDataType(PyArray_Descr * dtype);
5355
}
5456
#else
57+
#define call_PyArray_Check(py_obj) PyArray_Check(py_obj)
5558
#define call_PyArray_SimpleNew PyArray_SimpleNew
5659
#define call_PyArray_New(py_type_ptr,nd,shape,np_type,data_ptr,options) \
5760
PyArray_New(py_type_ptr,nd,shape,np_type,NULL,data_ptr,0,options,NULL)

src/numpy.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ namespace eigenpy
2222

2323
#if defined _WIN32 || defined __CYGWIN__
2424

25+
bool call_PyArray_Check(PyObject * py_obj)
26+
{
27+
return PyArray_Check(py_obj);
28+
}
29+
2530
PyObject* call_PyArray_SimpleNew(int nd, npy_intp * shape, int np_type)
2631
{
2732
return PyArray_SimpleNew(nd,shape,np_type);

0 commit comments

Comments
 (0)