From dfa2b53eeb1f33663b1f6888d66aebf2b36bd99c Mon Sep 17 00:00:00 2001 From: Ellon Mendes Date: Sat, 28 Nov 2015 00:35:39 +0100 Subject: [PATCH] import_array() --> import_array1() --- python/handwritten/exportgtsam.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/handwritten/exportgtsam.cpp b/python/handwritten/exportgtsam.cpp index e1dc646b1..da8382d71 100644 --- a/python/handwritten/exportgtsam.cpp +++ b/python/handwritten/exportgtsam.cpp @@ -59,8 +59,13 @@ void registerNumpyEigenConversions(); BOOST_PYTHON_MODULE(_libgtsam_python){ + // NOTE: We need to call import_array1() instead of import_array() to support both python 2 + // and 3. The reason is that BOOST_PYTHON_MODULE puts all its contents in a function + // returning void, and import_array() is a macro that when expanded for python 3, adds + // a 'return __null' statement to that function. For more info check files: + // boost/python/module_init.hpp and numpy/__multiarray_api.h (bottom of the file). // Should be the first thing to be done - import_array(); + import_array1(); registerNumpyEigenConversions();