Skip to content
Snippets Groups Projects
Verified Commit bb10b92d authored by Justin Carpentier's avatar Justin Carpentier
Browse files

core: move loadNumpyArray to the lib

no need to compile it again
parent 9765e55b
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "eigenpy/fwd.hpp" #include "eigenpy/fwd.hpp"
#include <patchlevel.h> // For PY_MAJOR_VERSION #include <patchlevel.h> // For PY_MAJOR_VERSION
#include <numpy/arrayobject.h>
#include <iostream> #include <iostream>
#include "eigenpy/eigenpy.hpp" #include "eigenpy/eigenpy.hpp"
...@@ -543,8 +542,6 @@ namespace eigenpy ...@@ -543,8 +542,6 @@ namespace eigenpy
} }
}; };
#define numpy_import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); } }
template<typename MatType,typename EigenEquivalentType> template<typename MatType,typename EigenEquivalentType>
void enableEigenPySpecific() void enableEigenPySpecific()
{ {
...@@ -581,7 +578,7 @@ namespace eigenpy ...@@ -581,7 +578,7 @@ namespace eigenpy
template<typename MatType> template<typename MatType>
void enableEigenPySpecific() void enableEigenPySpecific()
{ {
numpy_import_array(); loadNumpyArray();
if(check_registration<MatType>()) return; if(check_registration<MatType>()) return;
bp::to_python_converter<MatType,EigenToPy<MatType> >(); bp::to_python_converter<MatType,EigenToPy<MatType> >();
......
...@@ -26,6 +26,10 @@ ...@@ -26,6 +26,10 @@
namespace eigenpy namespace eigenpy
{ {
/* Load numpy through Python */
void loadNumpyArray();
/* Enable Eigen-Numpy serialization for a set of standard MatrixBase instance. */ /* Enable Eigen-Numpy serialization for a set of standard MatrixBase instance. */
void EIGENPY_EXPORT enableEigenPy(); void EIGENPY_EXPORT enableEigenPy();
......
...@@ -5,9 +5,24 @@ ...@@ -5,9 +5,24 @@
#include "eigenpy/eigenpy.hpp" #include "eigenpy/eigenpy.hpp"
#include <numpy/arrayobject.h>
namespace eigenpy namespace eigenpy
{ {
void loadNumpyArray()
{
static bool loaded = false;
if(loaded) return;
if(_import_array() < 0)
{
PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import");
}
else
loaded = true;
}
/* Enable Eigen-Numpy serialization for a set of standard MatrixBase instances. */ /* Enable Eigen-Numpy serialization for a set of standard MatrixBase instances. */
void enableEigenPy() void enableEigenPy()
{ {
......
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