Commit 782371c8 authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub

Merge pull request #118 from jcarpent/devel

Expose getNumpyType
parents 54a9826b 97529bb1
......@@ -114,6 +114,11 @@ namespace eigenpy
static NP_TYPE np_type;
return np_type;
}
static bp::object getNumpyType()
{
return getInstance().CurrentNumpyType;
}
protected:
NumpyType()
......
......@@ -16,7 +16,10 @@ namespace eigenpy
bp::def("setNumpyType",&NumpyType::setNumpyType,
bp::arg("Numpy type (np.ndarray or np.matrix)"),
"Change the type returned by the converters from an Eigen object.");
"Change the Numpy type returned by the converters from an Eigen object.");
bp::def("getNumpyType",&NumpyType::getNumpyType,
"Get the Numpy type returned by the converters from an Eigen object.");
bp::def("switchToNumpyArray",&NumpyType::switchToNumpyArray,
"Set the conversion from Eigen::Matrix to numpy.ndarray.");
......
from __future__ import print_function
from eigenpy import *
from geometry import *
import numpy as np
from numpy import cos,sin
......
......@@ -3,12 +3,14 @@ from __future__ import print_function
import eigenpy
import numpy as np
eigenpy.switchToNumpyMatrix()
quat = eigenpy.Quaternion()
# By default, we convert as numpy.matrix
coeffs_vector = quat.coeffs()
print(type(coeffs_vector))
assert isinstance(coeffs_vector,np.matrixlib.defmatrix.matrix)
assert eigenpy.getNumpyType() == np.matrix
# Switch to numpy.array
eigenpy.switchToNumpyArray()
......@@ -16,3 +18,4 @@ coeffs_array = quat.coeffs()
print(type(coeffs_array))
assert isinstance(coeffs_vector,np.ndarray)
assert eigenpy.getNumpyType() == np.ndarray
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment