File tree Expand file tree Collapse file tree 4 files changed +12
-2
lines changed Expand file tree Collapse file tree 4 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,11 @@ namespace eigenpy
114114 static NP_TYPE np_type;
115115 return np_type;
116116 }
117+
118+ static bp::object getNumpyType ()
119+ {
120+ return getInstance ().CurrentNumpyType ;
121+ }
117122
118123 protected:
119124 NumpyType ()
Original file line number Diff line number Diff line change @@ -16,7 +16,10 @@ namespace eigenpy
1616
1717 bp::def (" setNumpyType" ,&NumpyType::setNumpyType,
1818 bp::arg (" Numpy type (np.ndarray or np.matrix)" ),
19- " Change the type returned by the converters from an Eigen object." );
19+ " Change the Numpy type returned by the converters from an Eigen object." );
20+
21+ bp::def (" getNumpyType" ,&NumpyType::getNumpyType,
22+ " Get the Numpy type returned by the converters from an Eigen object." );
2023
2124 bp::def (" switchToNumpyArray" ,&NumpyType::switchToNumpyArray,
2225 " Set the conversion from Eigen::Matrix to numpy.ndarray." );
Original file line number Diff line number Diff line change 11from __future__ import print_function
22
3- from eigenpy import *
43from geometry import *
54import numpy as np
65from numpy import cos ,sin
Original file line number Diff line number Diff line change 33import eigenpy
44import numpy as np
55
6+ eigenpy .switchToNumpyMatrix ()
67quat = eigenpy .Quaternion ()
78# By default, we convert as numpy.matrix
89coeffs_vector = quat .coeffs ()
910print (type (coeffs_vector ))
1011
1112assert isinstance (coeffs_vector ,np .matrixlib .defmatrix .matrix )
13+ assert eigenpy .getNumpyType () == np .matrix
1214
1315# Switch to numpy.array
1416eigenpy .switchToNumpyArray ()
1517coeffs_array = quat .coeffs ()
1618print (type (coeffs_array ))
1719
1820assert isinstance (coeffs_vector ,np .ndarray )
21+ assert eigenpy .getNumpyType () == np .ndarray
You can’t perform that action at this time.
0 commit comments