From cdea91e1863b58e419bfbe1c820d52b8197e7b81 Mon Sep 17 00:00:00 2001 From: Justin Carpentier <justin.carpentier@inria.fr> Date: Fri, 19 Jul 2019 09:56:06 +0200 Subject: [PATCH] core: change variable naming to pyArray --- include/eigenpy/details.hpp | 40 ++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/include/eigenpy/details.hpp b/include/eigenpy/details.hpp index b3841a7e..6c6137c8 100644 --- a/include/eigenpy/details.hpp +++ b/include/eigenpy/details.hpp @@ -279,18 +279,18 @@ namespace eigenpy struct EigenFromPy { /// \brief Determine if pyObj can be converted into a MatType object - static void* convertible(PyArrayObject* pyObj) + static void* convertible(PyArrayObject* pyArray) { - if (!PyArray_Check(pyObj)) + if (!PyArray_Check(pyArray)) return 0; if(MatType::IsVectorAtCompileTime) { // Special care of scalar matrix of dimension 1x1. - if(PyArray_DIMS(pyObj)[0] == 1 && PyArray_DIMS(pyObj)[1] == 1) - return pyObj; + if(PyArray_DIMS(pyArray)[0] == 1 && PyArray_DIMS(pyArray)[1] == 1) + return pyArray; - if(PyArray_DIMS(pyObj)[0] > 1 && PyArray_DIMS(pyObj)[1] > 1) + if(PyArray_DIMS(pyArray)[0] > 1 && PyArray_DIMS(pyArray)[1] > 1) { #ifndef NDEBUG std::cerr << "The number of dimension of the object does not correspond to a vector" << std::endl; @@ -298,8 +298,8 @@ namespace eigenpy return 0; } - if(((PyArray_DIMS(pyObj)[0] == 1) && (MatType::ColsAtCompileTime == 1)) - || ((PyArray_DIMS(pyObj)[1] == 1) && (MatType::RowsAtCompileTime == 1))) + if(((PyArray_DIMS(pyArray)[0] == 1) && (MatType::ColsAtCompileTime == 1)) + || ((PyArray_DIMS(pyArray)[1] == 1) && (MatType::RowsAtCompileTime == 1))) { #ifndef NDEBUG if(MatType::ColsAtCompileTime == 1) @@ -311,9 +311,9 @@ namespace eigenpy } } - if (PyArray_NDIM(pyObj) != 2) + if (PyArray_NDIM(pyArray) != 2) { - if ( (PyArray_NDIM(pyObj) !=1) || (! MatType::IsVectorAtCompileTime) ) + if ( (PyArray_NDIM(pyArray) !=1) || (! MatType::IsVectorAtCompileTime) ) { #ifndef NDEBUG std::cerr << "The number of dimension of the object is not correct." << std::endl; @@ -322,10 +322,10 @@ namespace eigenpy } } - if (PyArray_NDIM(pyObj) == 2) + if (PyArray_NDIM(pyArray) == 2) { - const int R = (int)PyArray_DIMS(pyObj)[0]; - const int C = (int)PyArray_DIMS(pyObj)[1]; + const int R = (int)PyArray_DIMS(pyArray)[0]; + const int C = (int)PyArray_DIMS(pyArray)[1]; if( (MatType::RowsAtCompileTime!=R) && (MatType::RowsAtCompileTime!=Eigen::Dynamic) ) @@ -336,7 +336,7 @@ namespace eigenpy } // Check if the Scalar type of the obj_ptr is compatible with the Scalar type of MatType - if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyObj), 0)) == NPY_INT) + if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyArray), 0)) == NPY_INT) { if(!FromTypeToType<int,typename MatType::Scalar>::value) { @@ -346,7 +346,7 @@ namespace eigenpy return 0; } } - else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyObj), 0)) == NPY_LONG) + else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyArray), 0)) == NPY_LONG) { if(!FromTypeToType<long,typename MatType::Scalar>::value) { @@ -356,7 +356,7 @@ namespace eigenpy return 0; } } - else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyObj), 0)) == NPY_FLOAT) + else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyArray), 0)) == NPY_FLOAT) { if(!FromTypeToType<float,typename MatType::Scalar>::value) { @@ -366,7 +366,7 @@ namespace eigenpy return 0; } } - else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyObj), 0)) == NPY_DOUBLE) + else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyArray), 0)) == NPY_DOUBLE) { if(!FromTypeToType<double,typename MatType::Scalar>::value) { @@ -376,7 +376,7 @@ namespace eigenpy return 0; } } - else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyObj), 0)) + else if ((PyArray_ObjectType(reinterpret_cast<PyObject *>(pyArray), 0)) != NumpyEquivalentType<typename MatType::Scalar>::type_code) { #ifndef NDEBUG @@ -387,9 +387,9 @@ namespace eigenpy } #ifdef NPY_1_8_API_VERSION - if (!(PyArray_FLAGS(pyObj))) + if (!(PyArray_FLAGS(pyArray))) #else - if (!(PyArray_FLAGS(obj_ptr) & NPY_ALIGNED)) + if (!(PyArray_FLAGS(pyArray) & NPY_ALIGNED)) #endif { #ifndef NDEBUG @@ -398,7 +398,7 @@ namespace eigenpy return 0; } - return pyObj; + return pyArray; } /// \brief Allocate memory and copy pyObj in the new storage -- GitLab