Skip to content
GitLab
Menu
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
7e4439d1
Commit
7e4439d1
authored
Mar 19, 2018
by
Guilhem Saurel
Browse files
[Python] compatibility with 2.7 & 3.4
parent
2478b586
Changes
4
Hide whitespace changes
Inline
Side-by-side
.travis.yml
View file @
7e4439d1
language
:
generic
language
:
python
python
:
-
"
2.7"
-
"
3.4"
sudo
:
required
dist
:
trusty
compiler
:
...
...
@@ -9,7 +10,7 @@ compiler:
env
:
global
:
-
secure
:
"
SnIBG/xLIHX3CSvUbqqsX8xTVqIqQ7fFS6HWO6KZQVBsT6yugTwYHbyhNiU531JejYJ/I3ZrDhXfYH3qFZiYxnH1sifvwV+fnTtMXpPN7qPZwIymkjcmm6gJF51e0C7VOfUbvKFv0ngwj+ul21rgZSMuoEvxPK0WxtE3/ZSfn9c="
-
APT_DEPENDENCIES="doxygen libeigen3-dev "
-
APT_DEPENDENCIES="doxygen libeigen3-dev
libboost-test-dev libboost-python-dev libeigen3-dev
"
-
DEBSIGN_KEYID=5AE5CD75
-
CC=gcc
-
DO_COVERAGE_ON_BRANCH="master;release"
...
...
@@ -19,24 +20,18 @@ env:
-
BUILDTYPE=Release
-
BUILDTYPE=Debug
notifications
:
email
:
-
pinocchio@laas.fr
email
:
-
pinocchio
-build
@laas.fr
branches
:
only
:
-
master
-
debian
-
devel
matrix
:
allow_failures
:
-
compiler
:
before_install
:
./travis_custom/custom_before_install
install
:
-
pip install --user coveralls
-
pip install --user numpy
only
:
-
master
-
debian
-
devel
before_install
:
./.travis/run before_install
install
:
pip install coveralls numpy
script
:
-
export CMAKE_ADDITIONAL_OPTIONS="-DCMAKE_BUILD_TYPE=${BUILDTYPE}"
-
sudo free -m -t
-
./.travis/run ../travis_custom/custom_build
after_failure
:
./.travis/run after_failure
after_success
:
-
./.travis/run after_success
after_success
:
./.travis/run after_success
travis_custom/custom_before_install
deleted
100755 → 0
View file @
2478b586
#!/bin/bash
set
-e
# Setup environment variables.
export
APT_DEPENDENCIES
=
"doxygen libboost-test-dev libboost-python-dev libeigen3-dev python2.7-dev python-numpy"
# When this script is called the current directory is ./custom_travis
.
./.travis/run ../.travis/before_install
unittest/python/test_eigenpy.py
View file @
7e4439d1
from
__future__
import
print_function
import
numpy
as
np
import
matrix
as
eigenpy
verbose
=
False
if
verbose
:
print
"===> From MatrixXd to Py"
if
verbose
:
print
(
"===> From MatrixXd to Py"
)
M
=
eigenpy
.
naturals
(
3
,
3
,
verbose
)
Mcheck
=
np
.
reshape
(
np
.
matrix
(
range
(
9
),
np
.
double
),[
3
,
3
])
assert
np
.
array_equal
(
Mcheck
,
M
)
if
verbose
:
print
"===> From Matrix3d to Py"
if
verbose
:
print
(
"===> From Matrix3d to Py"
)
M33
=
eigenpy
.
naturals33
(
verbose
)
assert
np
.
array_equal
(
Mcheck
,
M33
)
if
verbose
:
print
"===> From VectorXd to Py"
if
verbose
:
print
(
"===> From VectorXd to Py"
)
v
=
eigenpy
.
naturalsX
(
3
,
verbose
)
vcheck
=
np
.
matrix
([
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"
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
])
if
verbose
:
print
"===> Matrix 8x8"
if
verbose
:
print
(
"===> Matrix 8x8"
)
M
=
Mref
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block 0:3x0:3"
if
verbose
:
print
(
"===> Block 0:3x0:3"
)
M
=
Mref
[
0
:
3
,
0
:
3
]
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block 1:3x1:3"
if
verbose
:
print
(
"===> Block 1:3x1:3"
)
M
=
Mref
[
1
:
3
,
1
:
3
]
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block 1:5:2x1:5:2"
if
verbose
:
print
(
"===> Block 1:5:2x1:5:2"
)
M
=
Mref
[
1
:
5
:
2
,
1
:
5
:
2
]
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block 1:8:3x1:5"
if
verbose
:
print
(
"===> Block 1:8:3x1:5"
)
M
=
Mref
[
1
:
8
:
3
,
1
:
5
]
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block transpose 1:8:3x1:6:2"
if
verbose
:
print
(
"===> Block transpose 1:8:3x1:6:2"
)
M
=
Mref
[
1
:
8
:
3
,
0
:
6
:
2
].
T
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block Vector 1x0:6:2"
if
verbose
:
print
(
"===> Block Vector 1x0:6:2"
)
M
=
Mref
[
1
:
2
,
0
:
6
:
2
]
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block Vector 1x0:6:2 tanspose"
if
verbose
:
print
(
"===> Block Vector 1x0:6:2 tanspose"
)
M
=
Mref
[
1
:
2
,
0
:
6
:
2
].
T
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block Vector 0:6:2x1"
if
verbose
:
print
(
"===> Block Vector 0:6:2x1"
)
M
=
Mref
[
0
:
6
:
2
,
1
:
2
]
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block Vector 0:6:2x1 tanspose"
if
verbose
:
print
(
"===> Block Vector 0:6:2x1 tanspose"
)
M
=
Mref
[
0
:
6
:
2
,
1
:
2
].
T
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex
(
M
,
verbose
))
);
if
verbose
:
print
"===> From Py to Eigen::VectorXd"
if
verbose
:
print
"===> From Py to Eigen::VectorXd"
if
verbose
:
print
"===> From Py to Eigen::VectorXd"
if
verbose
:
print
(
"===> From Py to Eigen::VectorXd"
)
if
verbose
:
print
(
"===> From Py to Eigen::VectorXd"
)
if
verbose
:
print
(
"===> From Py to Eigen::VectorXd"
)
if
verbose
:
print
"===> Block Vector 0:6:2x1 1 dim"
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
))
);
if
verbose
:
print
"===> Block Vector 0:6:2x1"
if
verbose
:
print
(
"===> Block Vector 0:6:2x1"
)
M
=
Mref
[
0
:
6
:
2
,
1
:
2
]
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflexV
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block Vector 0:6:2x1 transpose"
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
))
);
if
verbose
:
print
"===> From Py to Eigen::Matrix3d"
if
verbose
:
print
"===> From Py to Eigen::Matrix3d"
if
verbose
:
print
"===> From Py to Eigen::Matrix3d"
if
verbose
:
print
(
"===> From Py to Eigen::Matrix3d"
)
if
verbose
:
print
(
"===> From Py to Eigen::Matrix3d"
)
if
verbose
:
print
(
"===> From Py to Eigen::Matrix3d"
)
if
verbose
:
print
"===> Block Vector 0:3x0:6:2 "
if
verbose
:
print
(
"===> Block Vector 0:3x0:6:2 "
)
M
=
Mref
[
0
:
3
,
0
:
6
:
2
]
assert
(
np
.
array_equal
(
M
,
eigenpy
.
reflex33
(
M
,
verbose
))
);
if
verbose
:
print
"===> Block Vector 0:3x0:6:2 T"
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
,
e
:
if
verbose
:
print
"As expected, got the following /ROW/ error:"
,
e
.
message
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"
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
))
);
...
...
unittest/python/test_geometry.py
View file @
7e4439d1
from
__future__
import
print_function
from
geometry
import
*
import
numpy
as
np
from
numpy
import
cos
,
sin
...
...
@@ -33,13 +35,13 @@ assert(isapprox(q.coeffs(),qR.coeffs()))
assert
(
isapprox
(
qR
[
3
],
1.
/
np
.
sqrt
(
30
)))
try
:
qR
[
5
]
print
"Error, this message should not appear."
except
Exception
,
e
:
if
verbose
:
print
"As expected, catched exception: "
,
e
.
message
print
(
"Error, this message should not appear."
)
except
Exception
as
e
:
if
verbose
:
print
(
"As expected, catched exception: "
,
e
.
message
)
# --- Angle Vector ------------------------------------------------
r
=
AngleAxis
(.
1
,
np
.
array
([
1
,
0
,
0
],
np
.
double
))
if
verbose
:
print
"Rx(.1) =
\n\n
"
,
r
.
matrix
(),
"
\n
"
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
)
)
...
...
@@ -66,6 +68,6 @@ res = testInQuaternion_fx(q)
assert
(
q
.
norm
()
==
res
)
try
:
testInQuaternion
(
q
)
print
"Error, this message should not appear."
print
(
"Error, this message should not appear."
)
except
:
if
verbose
:
print
"As expected, catch a Boost::python::ArgError exception."
if
verbose
:
print
(
"As expected, catch a Boost::python::ArgError exception."
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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