diff --git a/src/eigenpy.hpp b/src/eigenpy.hpp index 04e99d5dcf34af44eff012153bbb57a844c89bbf..60dfdd013fc9f219d9a13c76f7623f650da3e06d 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(); } };