From 211ab1b2bddcd22dc7c0ab5ca5cdb0f3b52cf7b8 Mon Sep 17 00:00:00 2001 From: Mansard <nmansard@laas.fr> Date: Tue, 16 Sep 2014 09:22:03 +0200 Subject: [PATCH] Added a conversion to matrix type. --- src/eigenpy.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/eigenpy.hpp b/src/eigenpy.hpp index 04e99d5d..60dfdd01 100644 --- a/src/eigenpy.hpp +++ b/src/eigenpy.hpp @@ -60,7 +60,15 @@ namespace eigenpy MapNumpy<EquivalentEigenType>::map(pyArray) = mat; - return (PyObject*)pyArray; + + boost::python::object pyModule = boost::python::import("numpy"); + boost::python::object pyMatrixType = pyModule.attr("matrix"); + + boost::python::object m + = pyMatrixType( boost::python::object(boost::python::handle<>((PyObject*)pyArray)), + boost::python::object(), true ); + Py_INCREF(m.ptr()); + return m.ptr(); } }; -- GitLab