Skip to content
Snippets Groups Projects
Verified Commit 637b9bb9 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

numpy: add helper for the switch

parent 81c5ae64
No related branches found
No related tags found
No related merge requests found
......@@ -86,19 +86,30 @@ namespace eigenpy
if(PyType_IsSubtype(obj_type,getInstance().NumpyMatrixType))
getInstance().CurrentNumpyType = getInstance().NumpyMatrixObject;
else if(PyType_IsSubtype(obj_type,getInstance().NumpyArrayType))
getInstance().CurrentNumpyType = getInstance().NumpyArrayObject;;
getInstance().CurrentNumpyType = getInstance().NumpyArrayObject;
}
static void switchToNumpyArray()
{
getInstance().CurrentNumpyType = getInstance().NumpyArrayObject;
}
static void switchToNumpyMatrix()
{
getInstance().CurrentNumpyType = getInstance().NumpyMatrixObject;
}
protected:
PyMatrixType()
{
pyModule = bp::import("numpy");
CurrentNumpyType = pyModule.attr("matrix"); // default conversion
NumpyMatrixObject = pyModule.attr("matrix");
NumpyMatrixType = reinterpret_cast<PyTypeObject*>(NumpyMatrixObject.ptr());
NumpyArrayObject = pyModule.attr("ndarray");
NumpyArrayType = reinterpret_cast<PyTypeObject*>(NumpyArrayObject.ptr());
CurrentNumpyType = NumpyMatrixObject; // default conversion
}
bp::object CurrentNumpyType;
......@@ -107,9 +118,6 @@ namespace eigenpy
// Numpy types
bp::object NumpyMatrixObject; PyTypeObject * NumpyMatrixType;
bp::object NumpyArrayObject; PyTypeObject * NumpyArrayType;
// PyTypeObject * NumpyArrayType;
};
template<typename MatType>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment