Commit bb10b92d authored by Justin Carpentier's avatar Justin Carpentier

core: move loadNumpyArray to the lib

no need to compile it again
parent 9765e55b
......@@ -10,7 +10,6 @@
#include "eigenpy/fwd.hpp"
#include <patchlevel.h> // For PY_MAJOR_VERSION
#include <numpy/arrayobject.h>
#include <iostream>
#include "eigenpy/eigenpy.hpp"
......@@ -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>
void enableEigenPySpecific()
{
......@@ -581,7 +578,7 @@ namespace eigenpy
template<typename MatType>
void enableEigenPySpecific()
{
numpy_import_array();
loadNumpyArray();
if(check_registration<MatType>()) return;
bp::to_python_converter<MatType,EigenToPy<MatType> >();
......
......@@ -26,6 +26,10 @@
namespace eigenpy
{
/* Load numpy through Python */
void loadNumpyArray();
/* Enable Eigen-Numpy serialization for a set of standard MatrixBase instance. */
void EIGENPY_EXPORT enableEigenPy();
......
......@@ -5,9 +5,24 @@
#include "eigenpy/eigenpy.hpp"
#include <numpy/arrayobject.h>
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. */
void enableEigenPy()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment