Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions include/eigenpy/details.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ namespace eigenpy

enum NP_TYPE
{
DEFAULT_TYPE,
MATRIX_TYPE,
ARRAY_TYPE
};
Expand All @@ -176,16 +175,6 @@ namespace eigenpy

bp::object make(PyObject* pyObj, bool copy = false)
{
if (getType() == DEFAULT_TYPE) {
std::cerr <<
"eigenpy warning: you use the deprecated class numpy.matrix without explicily asking for it. "
"The default behaviour will change to numpy.array at next major release.\n"
"- Either call eigenpy.switchToNumpyMatrix() before using eigenpy to suppress this warning\n"
"- or call eigenpy.switchToNumpyArray() and adapt your code accordingly.\n"
"See https://github.com/stack-of-tasks/eigenpy/issues/87 for further details."
<< std::endl;
switchToNumpyMatrix();
}
bp::object m;
if(PyType_IsSubtype(reinterpret_cast<PyTypeObject*>(CurrentNumpyType.ptr()),NumpyMatrixType))
m = NumpyMatrixObject(bp::object(bp::handle<>(pyObj)), bp::object(), copy);
Expand Down Expand Up @@ -268,8 +257,8 @@ namespace eigenpy
//NumpyAsMatrixObject = pyModule.attr("asmatrix");
//NumpyAsMatrixType = reinterpret_cast<PyTypeObject*>(NumpyAsMatrixObject.ptr());

CurrentNumpyType = NumpyMatrixObject; // default conversion
getType() = DEFAULT_TYPE;
CurrentNumpyType = NumpyArrayObject; // default conversion
getType() = ARRAY_TYPE;
}

bp::object CurrentNumpyType;
Expand Down
8 changes: 4 additions & 4 deletions unittest/python/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def isapprox(a,b,epsilon=1e-6):

Rq = q.matrix()
Rr = r.matrix()
assert(isapprox(Rq*Rq.T,np.eye(3)))
assert(isapprox(Rq.dot(Rq.T),np.eye(3)))
assert(isapprox(Rr,Rq))

qR = Quaternion(Rr)
Expand All @@ -42,15 +42,15 @@ def isapprox(a,b,epsilon=1e-6):
if verbose: print("As expected, catched exception: ",e)

# --- Angle Vector ------------------------------------------------
r = AngleAxis(.1,np.matrix([1,0,0],np.double).T)
r = AngleAxis(.1,np.array([1,0,0],np.double))
if verbose: print("Rx(.1) = \n\n",r.matrix(),"\n")
assert( isapprox(r.matrix()[2,2],cos(r.angle)))
assert( isapprox(r.axis,np.matrix("1;0;0")) )
assert( isapprox(r.axis,np.array([1.,0,0])) )
assert( isapprox(r.angle,0.1) )
assert(r.isApprox(r))
assert(r.isApprox(r,1e-2))

r.axis = np.matrix([0,1,0],np.double).T
r.axis = np.array([0,1,0],np.double).T
assert( isapprox(r.matrix()[0,0],cos(r.angle)))

ri = r.inverse()
Expand Down
10 changes: 5 additions & 5 deletions unittest/python/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

if verbose: print("===> From empty VectorXd to Py")
v = eigenpy.emptyVector()
assert v.shape == (0,1)
assert v.shape == (0,)

if verbose: print("===> From MatrixXd to Py")
M = eigenpy.naturals(3,3,verbose)
Mcheck = np.reshape(np.matrix(range(9),np.double),[3,3])
Mcheck = np.reshape(np.array(range(9),np.double),[3,3])
assert np.array_equal(Mcheck,M)

if verbose: print("===> From Matrix3d to Py")
Expand All @@ -24,13 +24,13 @@

if verbose: print("===> From VectorXd to Py")
v = eigenpy.naturalsX(3,verbose)
vcheck = np.matrix([range(3),],np.double).T
vcheck = np.array(range(3),np.double).T
assert np.array_equal(vcheck ,v)

if verbose: print("===> From Py to Eigen::MatrixXd")
if verbose: print("===> From Py to Eigen::MatrixXd")
if verbose: print("===> From Py to Eigen::MatrixXd")
Mref = np.reshape(np.matrix(range(64),np.double),[8,8])
Mref = np.reshape(np.array(range(64),np.double),[8,8])

# Test base function
Mref_from_base = eigenpy.base(Mref)
Expand Down Expand Up @@ -125,4 +125,4 @@

vec1x1 = eigenpy.vector1x1(value)
assert(vec1x1.size == 1)
assert(vec1x1[0,0] == value)
assert(vec1x1[0] == value)