Skip to content

Commit a28bcaa

Browse files
committed
test: update test to account for alignment issues
1 parent a85b2f6 commit a28bcaa

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

unittest/python/test_geometry.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def isapprox(a, b, epsilon=1e-6):
3232
# Coefficient-vector initialisation
3333
verbose and print("[Quaternion] Coefficient-vector initialisation")
3434
v = np.array([0.5, -0.5, 0.5, 0.5])
35-
qv = Quaternion(v)
35+
for k in range(10000):
36+
qv = Quaternion(v)
3637
assert isapprox(qv.coeffs(), v)
3738

3839
# Angle axis initialisation

unittest/python/test_std_vector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def checkZero(l):
5353

5454

5555
print("Check setZero() works:")
56-
print("l1:")
5756
std_vector.setZero(l1)
57+
print("l1:")
5858
print(l1)
5959
checkZero(l1)
6060
print("-----------------")

unittest/std_vector.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,26 @@
77
#include "eigenpy/eigen-from-python.hpp"
88
#include "eigenpy/std-vector.hpp"
99

10-
template <typename MatType>
11-
void printVectorOfMatrix(const std::vector<MatType> &Ms) {
10+
template <typename MatType,
11+
typename Allocator = Eigen::aligned_allocator<MatType> >
12+
void printVectorOfMatrix(const std::vector<MatType, Allocator> &Ms) {
1213
const std::size_t n = Ms.size();
1314
for (std::size_t i = 0; i < n; i++) {
1415
std::cout << "el[" << i << "] =\n" << Ms[i] << '\n';
1516
}
1617
}
1718

18-
template <typename MatType>
19-
std::vector<MatType> copy(const std::vector<MatType> &Ms) {
20-
std::vector<MatType> out = Ms;
19+
template <typename MatType,
20+
typename Allocator = Eigen::aligned_allocator<MatType> >
21+
std::vector<MatType, Allocator> copy(
22+
const std::vector<MatType, Allocator> &Ms) {
23+
std::vector<MatType, Allocator> out = Ms;
2124
return out;
2225
}
2326

24-
template <typename MatType>
25-
void setZero(std::vector<MatType> &Ms) {
27+
template <typename MatType,
28+
typename Allocator = Eigen::aligned_allocator<MatType> >
29+
void setZero(std::vector<MatType, Allocator> &Ms) {
2630
for (std::size_t i = 0; i < Ms.size(); i++) {
2731
Ms[i].setZero();
2832
}

0 commit comments

Comments
 (0)