Skip to content

Commit

Permalink
core: Fix std_vector unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Joris Vaillant committed Oct 25, 2023
1 parent dfc054e commit 774c934
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
16 changes: 10 additions & 6 deletions unittest/python/test_std_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,15 @@ def checkZero(l):
# pprint.pprint(list(l4))
# checkZero(l4)

# TODO fail
l5_copy = std_vector.StdVec_Mat2d(l5)
# Test StdVec_Mat2d that had been registered
# before calling exposeStdVectorEigenSpecificType

# test l5 == l5_copy == l5_py
# Test conversion and tolistl5 == l5_copy == l5_py
l5_copy = std_vector.StdVec_Mat2d(l5)
l5_py = l5_copy.tolist()
# Test l5[0] is zero
l5[0].setZero()
# TODO test
checkAllValues(l5, l5_copy)
checkAllValues(l5, l5_py)

# Test mutable __getitem__
l5[0][:] = 0.0
assert np.allclose(l5[0], 0.0)
5 changes: 3 additions & 2 deletions unittest/std_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ BOOST_PYTHON_MODULE(std_vector) {

// Test matrix modification
// Mat2d don't have tolist, reserve, mutable __getitem__ and from list
// conversion exposeStdVectorEigenSpecificType must add those methods to Mat2d
// conversion
// exposeStdVectorEigenSpecificType must add those methods to StdVec_Mat2d
bp::class_<std::vector<Eigen::Matrix2d> >("StdVec_Mat2d")
.def(boost::python::vector_indexing_suite<
std::vector<Eigen::Matrix2d> >());
exposeStdVectorEigenSpecificType<Eigen::Matrix3d>("Mat2d");
exposeStdVectorEigenSpecificType<Eigen::Matrix2d>("Mat2d");
}

0 comments on commit 774c934

Please sign in to comment.