Skip to content

Commit e168c2f

Browse files
committed
core: use GET_PY_ARRAY_TYPE when possible
1 parent cdea91e commit e168c2f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

include/eigenpy/details.hpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ namespace eigenpy
336336
}
337337

338338
// Check if the Scalar type of the obj_ptr is compatible with the Scalar type of MatType
339-
if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyArray), 0)) == NPY_INT)
339+
if(GET_PY_ARRAY_TYPE(pyArray) == NPY_INT)
340340
{
341341
if(!FromTypeToType<int,typename MatType::Scalar>::value)
342342
{
@@ -346,7 +346,7 @@ namespace eigenpy
346346
return 0;
347347
}
348348
}
349-
else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyArray), 0)) == NPY_LONG)
349+
else if(GET_PY_ARRAY_TYPE(pyArray) == NPY_LONG)
350350
{
351351
if(!FromTypeToType<long,typename MatType::Scalar>::value)
352352
{
@@ -356,7 +356,7 @@ namespace eigenpy
356356
return 0;
357357
}
358358
}
359-
else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyArray), 0)) == NPY_FLOAT)
359+
else if(GET_PY_ARRAY_TYPE(pyArray) == NPY_FLOAT)
360360
{
361361
if(!FromTypeToType<float,typename MatType::Scalar>::value)
362362
{
@@ -366,7 +366,7 @@ namespace eigenpy
366366
return 0;
367367
}
368368
}
369-
else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyArray), 0)) == NPY_DOUBLE)
369+
else if(GET_PY_ARRAY_TYPE(pyArray) == NPY_DOUBLE)
370370
{
371371
if(!FromTypeToType<double,typename MatType::Scalar>::value)
372372
{
@@ -376,8 +376,7 @@ namespace eigenpy
376376
return 0;
377377
}
378378
}
379-
else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyArray), 0))
380-
!= NumpyEquivalentType<typename MatType::Scalar>::type_code)
379+
else if(GET_PY_ARRAY_TYPE(pyArray) != NumpyEquivalentType<typename MatType::Scalar>::type_code)
381380
{
382381
#ifndef NDEBUG
383382
std::cerr << "The internal type as no Eigen equivalent." << std::endl;

0 commit comments

Comments
 (0)