Skip to content

Commit 32515e7

Browse files
Joris Vaillantjcarpent
authored andcommitted
core: Fix std_vector unit tests
1 parent 727fad6 commit 32515e7

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

unittest/python/test_std_vector.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,15 @@ def checkZero(l):
8585
# pprint.pprint(list(l4))
8686
# checkZero(l4)
8787

88-
# TODO fail
89-
l5_copy = std_vector.StdVec_Mat2d(l5)
88+
# Test StdVec_Mat2d that had been registered
89+
# before calling exposeStdVectorEigenSpecificType
9090

91-
# test l5 == l5_copy == l5_py
91+
# Test conversion and tolistl5 == l5_copy == l5_py
92+
l5_copy = std_vector.StdVec_Mat2d(l5)
9293
l5_py = l5_copy.tolist()
93-
# Test l5[0] is zero
94-
l5[0].setZero()
95-
# TODO test
94+
checkAllValues(l5, l5_copy)
95+
checkAllValues(l5, l5_py)
96+
97+
# Test mutable __getitem__
98+
l5[0][:] = 0.0
99+
assert np.allclose(l5[0], 0.0)

unittest/std_vector.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ BOOST_PYTHON_MODULE(std_vector) {
5252

5353
// Test matrix modification
5454
// Mat2d don't have tolist, reserve, mutable __getitem__ and from list
55-
// conversion exposeStdVectorEigenSpecificType must add those methods to Mat2d
55+
// conversion
56+
// exposeStdVectorEigenSpecificType must add those methods to StdVec_Mat2d
5657
bp::class_<std::vector<Eigen::Matrix2d> >("StdVec_Mat2d")
5758
.def(boost::python::vector_indexing_suite<
5859
std::vector<Eigen::Matrix2d> >());
59-
exposeStdVectorEigenSpecificType<Eigen::Matrix3d>("Mat2d");
60+
exposeStdVectorEigenSpecificType<Eigen::Matrix2d>("Mat2d");
6061
}

0 commit comments

Comments
 (0)