diff --git a/python/handwritten/exportgtsam.cpp b/python/handwritten/exportgtsam.cpp index 2424cd4da..84585adff 100644 --- a/python/handwritten/exportgtsam.cpp +++ b/python/handwritten/exportgtsam.cpp @@ -18,6 +18,8 @@ #include #include +#include + #include #include @@ -55,6 +57,8 @@ void registerNumpyEigenConversions(); BOOST_PYTHON_MODULE(libgtsam_python){ // Should be the first thing to be done + import_array(); + registerNumpyEigenConversions(); exportPoint2(); diff --git a/python/handwritten/geometry/Point2.cpp b/python/handwritten/geometry/Point2.cpp index f94d8ef1e..7af3f8cf6 100644 --- a/python/handwritten/geometry/Point2.cpp +++ b/python/handwritten/geometry/Point2.cpp @@ -16,6 +16,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/geometry/Point2.h" using namespace boost::python; diff --git a/python/handwritten/geometry/Point3.cpp b/python/handwritten/geometry/Point3.cpp index 99adff5f2..664b4ffda 100644 --- a/python/handwritten/geometry/Point3.cpp +++ b/python/handwritten/geometry/Point3.cpp @@ -16,6 +16,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/geometry/Point3.h" using namespace boost::python; diff --git a/python/handwritten/geometry/Pose2.cpp b/python/handwritten/geometry/Pose2.cpp index 6640d47a9..4f402df7e 100644 --- a/python/handwritten/geometry/Pose2.cpp +++ b/python/handwritten/geometry/Pose2.cpp @@ -16,6 +16,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/geometry/Pose2.h" using namespace boost::python; diff --git a/python/handwritten/geometry/Pose3.cpp b/python/handwritten/geometry/Pose3.cpp index 2257bab46..11b09608d 100644 --- a/python/handwritten/geometry/Pose3.cpp +++ b/python/handwritten/geometry/Pose3.cpp @@ -16,6 +16,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/geometry/Pose3.h" #include "gtsam/geometry/Pose2.h" diff --git a/python/handwritten/geometry/Rot2.cpp b/python/handwritten/geometry/Rot2.cpp index d7bcf8cf1..59b4ce4e8 100644 --- a/python/handwritten/geometry/Rot2.cpp +++ b/python/handwritten/geometry/Rot2.cpp @@ -16,6 +16,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/geometry/Rot2.h" using namespace boost::python; diff --git a/python/handwritten/geometry/Rot3.cpp b/python/handwritten/geometry/Rot3.cpp index 8c82e5396..ff2b61b63 100644 --- a/python/handwritten/geometry/Rot3.cpp +++ b/python/handwritten/geometry/Rot3.cpp @@ -16,6 +16,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/geometry/Rot3.h" using namespace boost::python; diff --git a/python/handwritten/linear/NoiseModel.cpp b/python/handwritten/linear/NoiseModel.cpp index 2b492b7e5..3453184bd 100644 --- a/python/handwritten/linear/NoiseModel.cpp +++ b/python/handwritten/linear/NoiseModel.cpp @@ -23,6 +23,9 @@ #include +#define NO_IMPORT_ARRAY +#include + #include "gtsam/linear/NoiseModel.h" using namespace boost::python; diff --git a/python/handwritten/nonlinear/ISAM2.cpp b/python/handwritten/nonlinear/ISAM2.cpp index d55da3752..9c042a011 100644 --- a/python/handwritten/nonlinear/ISAM2.cpp +++ b/python/handwritten/nonlinear/ISAM2.cpp @@ -15,6 +15,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/nonlinear/ISAM2.h" using namespace boost::python; diff --git a/python/handwritten/nonlinear/LevenbergMarquardtOptimizer.cpp b/python/handwritten/nonlinear/LevenbergMarquardtOptimizer.cpp index b7e38359f..44b11f00b 100644 --- a/python/handwritten/nonlinear/LevenbergMarquardtOptimizer.cpp +++ b/python/handwritten/nonlinear/LevenbergMarquardtOptimizer.cpp @@ -1,4 +1,8 @@ #include + +#define NO_IMPORT_ARRAY +#include + #include using namespace boost::python; diff --git a/python/handwritten/nonlinear/NonlinearFactor.cpp b/python/handwritten/nonlinear/NonlinearFactor.cpp index e111f65f7..9a130d8e9 100644 --- a/python/handwritten/nonlinear/NonlinearFactor.cpp +++ b/python/handwritten/nonlinear/NonlinearFactor.cpp @@ -15,6 +15,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/nonlinear/NonlinearFactor.h" using namespace boost::python; diff --git a/python/handwritten/nonlinear/NonlinearFactorGraph.cpp b/python/handwritten/nonlinear/NonlinearFactorGraph.cpp index a2262f9fd..830e16898 100644 --- a/python/handwritten/nonlinear/NonlinearFactorGraph.cpp +++ b/python/handwritten/nonlinear/NonlinearFactorGraph.cpp @@ -16,6 +16,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/nonlinear/NonlinearFactorGraph.h" #include "gtsam/nonlinear/NonlinearFactor.h" diff --git a/python/handwritten/nonlinear/Values.cpp b/python/handwritten/nonlinear/Values.cpp index 7d68e88c8..021cf019f 100644 --- a/python/handwritten/nonlinear/Values.cpp +++ b/python/handwritten/nonlinear/Values.cpp @@ -15,6 +15,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/nonlinear/Values.h" #include "gtsam/geometry/Point3.h" #include "gtsam/geometry/Rot3.h" diff --git a/python/handwritten/slam/BearingFactor.cpp b/python/handwritten/slam/BearingFactor.cpp index b13d1f281..84c67d522 100644 --- a/python/handwritten/slam/BearingFactor.cpp +++ b/python/handwritten/slam/BearingFactor.cpp @@ -1,4 +1,8 @@ #include + +#define NO_IMPORT_ARRAY +#include + #include using namespace boost::python; diff --git a/python/handwritten/slam/BetweenFactor.cpp b/python/handwritten/slam/BetweenFactor.cpp index 428f54e6f..b6fc552a0 100644 --- a/python/handwritten/slam/BetweenFactor.cpp +++ b/python/handwritten/slam/BetweenFactor.cpp @@ -16,6 +16,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/slam/BetweenFactor.h" #include "gtsam/geometry/Point2.h" #include "gtsam/geometry/Rot2.h" diff --git a/python/handwritten/slam/PriorFactor.cpp b/python/handwritten/slam/PriorFactor.cpp index 6004c9957..dcb9de8ea 100644 --- a/python/handwritten/slam/PriorFactor.cpp +++ b/python/handwritten/slam/PriorFactor.cpp @@ -16,6 +16,10 @@ **/ #include + +#define NO_IMPORT_ARRAY +#include + #include "gtsam/slam/PriorFactor.h" #include "gtsam/geometry/Point2.h" #include "gtsam/geometry/Rot2.h" diff --git a/python/handwritten/utils/NumpyEigen.cpp b/python/handwritten/utils/NumpyEigen.cpp index 82d3b6d5a..d7cebe7ad 100644 --- a/python/handwritten/utils/NumpyEigen.cpp +++ b/python/handwritten/utils/NumpyEigen.cpp @@ -14,8 +14,9 @@ * @author Ellon Paiva Mendes (LAAS-CNRS) **/ - #include +#include +#define NO_IMPORT_ARRAY #include #include "gtsam/base/Matrix.h" @@ -26,7 +27,8 @@ using namespace gtsam; void registerNumpyEigenConversions() { - import_array(); + // NOTE: import array should be called only in the cpp defining the module + // import_array(); NumpyEigenConverter::register_converter(); NumpyEigenConverter::register_converter(); NumpyEigenConverter::register_converter();