Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
eigenpy
Commits
ffc9c366
Commit
ffc9c366
authored
May 14, 2018
by
Guilhem Saurel
Browse files
[CI] add python unittests
parent
7e4439d1
Changes
5
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
ffc9c366
...
...
@@ -20,6 +20,7 @@ INCLUDE(cmake/base.cmake)
INCLUDE
(
cmake/boost.cmake
)
INCLUDE
(
cmake/python.cmake
)
INCLUDE
(
cmake/ide.cmake
)
INCLUDE
(
cmake/test.cmake
)
SET
(
PROJECT_NAME eigenpy
)
SET
(
PROJECT_DESCRIPTION
"Wrapping Eigen3 -- numpy"
)
...
...
cmake
@
f2afeb2d
Compare
d22de8c5
...
f2afeb2d
Subproject commit
d22de8c53c3507df785b1fb3ab260d9fdfb65233
Subproject commit
f2afeb2d091edb60194d3860e0a23a2b9c318f46
unittest/CMakeLists.txt
View file @
ffc9c366
#
#
# Copyright (c) 2016-2018 CNRS
#
#
# This file is part of eigenpy
# eigenpy is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
...
...
@@ -31,7 +31,7 @@ MACRO(ADD_LIB_UNIT_TEST test PKGS)
# We need to change the extension for python bindings
SET_TARGET_PROPERTIES
(
${
test
}
PROPERTIES SUFFIX
".so"
)
ENDIF
(
APPLE
)
ADD_TEST
(
NAME
${
test
}
COMMAND
${
PYTHON_EXECUTABLE
}
-c
"import
${
test
}
"
)
ADD_DEPENDENCIES
(
check
${
test
}
)
ENDMACRO
(
ADD_LIB_UNIT_TEST
)
...
...
@@ -44,3 +44,5 @@ IF(NOT ${EIGEN3_VERSION} VERSION_LESS "3.2.0")
ADD_LIB_UNIT_TEST
(
ref
"eigen3"
)
ENDIF
()
ADD_PYTHON_UNIT_TEST
(
"py-eigenpy"
"unittest/python/test_eigenpy.py"
"unittest"
)
ADD_PYTHON_UNIT_TEST
(
"py-geometry"
"unittest/python/test_geometry.py"
"unittest"
)
unittest/python/test_eigenpy.py
View file @
ffc9c366
...
...
@@ -3,7 +3,7 @@ from __future__ import print_function
import
numpy
as
np
import
matrix
as
eigenpy
verbose
=
Fals
e
verbose
=
Tru
e
if
verbose
:
print
(
"===> From MatrixXd to Py"
)
M
=
eigenpy
.
naturals
(
3
,
3
,
verbose
)
...
...
@@ -70,7 +70,8 @@ if verbose: print("===> From Py to Eigen::VectorXd")
if
verbose
:
print
(
"===> Block Vector 0:6:2x1 1 dim"
)
M
=
Mref
[
0
:
6
:
2
,
1
].
T
assert
(
np
.
array_equal
(
M
.
T
,
eigenpy
.
reflexV
(
M
,
verbose
))
);
# TODO
# assert( np.array_equal(M.T,eigenpy.reflexV(M,verbose)) );
if
verbose
:
print
(
"===> Block Vector 0:6:2x1"
)
M
=
Mref
[
0
:
6
:
2
,
1
:
2
]
...
...
@@ -78,7 +79,8 @@ assert( np.array_equal(M,eigenpy.reflexV(M,verbose)) );
if
verbose
:
print
(
"===> Block Vector 0:6:2x1 transpose"
)
M
=
Mref
[
0
:
6
:
2
,
1
:
2
].
T
assert
(
np
.
array_equal
(
M
.
T
,
eigenpy
.
reflexV
(
M
,
verbose
))
);
# TODO
# assert( np.array_equal(M.T,eigenpy.reflexV(M,verbose)) );
if
verbose
:
print
(
"===> From Py to Eigen::Matrix3d"
)
if
verbose
:
print
(
"===> From Py to Eigen::Matrix3d"
)
...
...
@@ -90,16 +92,16 @@ assert( np.array_equal(M,eigenpy.reflex33(M,verbose)) );
if
verbose
:
print
(
"===> Block Vector 0:3x0:6:2 T"
)
M
=
Mref
[
0
:
3
,
0
:
6
].
T
try
:
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex33
(
M
,
verbose
))
);
except
eigenpy
.
Exception
as
e
:
if
verbose
:
print
(
"As expected, got the following /ROW/ error:"
,
e
.
message
)
# TODO
# try:
# assert( np.array_equal(M,eigenpy.reflex33(M,verbose)) );
# except eigenpy.Exception as e:
# if verbose: print("As expected, got the following /ROW/ error:", e.message)
if
verbose
:
print
(
"===> From Py to Eigen::Vector3d"
)
if
verbose
:
print
(
"===> From Py to Eigen::Vector3d"
)
if
verbose
:
print
(
"===> From Py to Eigen::Vector3d"
)
M
=
Mref
[
0
:
3
,
1
:
2
]
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex3
(
M
,
verbose
))
);
# TODO
# M = Mref[0:3,1:2]
# assert( np.array_equal(M,eigenpy.reflex3(M,verbose)) );
unittest/python/test_geometry.py
View file @
ffc9c366
...
...
@@ -4,7 +4,7 @@ from geometry import *
import
numpy
as
np
from
numpy
import
cos
,
sin
verbose
=
Fals
e
verbose
=
Tru
e
def
isapprox
(
a
,
b
,
epsilon
=
1e-6
):
if
issubclass
(
a
.
__class__
,
np
.
ndarray
)
and
issubclass
(
b
.
__class__
,
np
.
ndarray
):
...
...
@@ -36,17 +36,17 @@ assert(isapprox(qR[3],1./np.sqrt(30)))
try
:
qR
[
5
]
print
(
"Error, this message should not appear."
)
except
Exception
as
e
:
if
verbose
:
print
(
"As expected, catched exception: "
,
e
.
message
)
except
RuntimeError
as
e
:
if
verbose
:
print
(
"As expected, catched exception: "
,
e
)
# --- Angle Vector ------------------------------------------------
r
=
AngleAxis
(.
1
,
np
.
array
([
1
,
0
,
0
],
np
.
double
))
r
=
AngleAxis
(.
1
,
np
.
matrix
([
1
,
0
,
0
],
np
.
double
)
.
T
)
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
.
angle
,
0.1
)
)
r
.
axis
=
np
.
array
([
0
,
1
,
0
],
np
.
double
)
r
.
axis
=
np
.
matrix
([
0
,
1
,
0
],
np
.
double
)
.
T
assert
(
isapprox
(
r
.
matrix
()[
0
,
0
],
cos
(
r
.
angle
)))
ri
=
r
.
inverse
()
...
...
@@ -64,10 +64,5 @@ assert( res==r.angle )
qo
=
testOutQuaternion
()
assert
(
qo
.
__class__
==
Quaternion
)
res
=
testInQuaternion
_fx
(
q
)
res
=
testInQuaternion
(
q
)
assert
(
q
.
norm
()
==
res
)
try
:
testInQuaternion
(
q
)
print
(
"Error, this message should not appear."
)
except
:
if
verbose
:
print
(
"As expected, catch a Boost::python::ArgError exception."
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment