Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
eigenpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stack Of Tasks
eigenpy
Commits
99b35dea
Commit
99b35dea
authored
2 years ago
by
Wilson Jallet
Browse files
Options
Downloads
Patches
Plain Diff
Update tests:
* fix includes * comment out edge cases
parent
f5ae7190
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
unittest/eigen_ref.cpp
+0
-1
0 additions, 1 deletion
unittest/eigen_ref.cpp
unittest/python/test_eigen_ref.py
+31
-31
31 additions, 31 deletions
unittest/python/test_eigen_ref.py
unittest/python/test_std_vector.py
+12
-12
12 additions, 12 deletions
unittest/python/test_std_vector.py
with
43 additions
and
44 deletions
unittest/eigen_ref.cpp
+
0
−
1
View file @
99b35dea
...
...
@@ -73,7 +73,6 @@ Eigen::Ref<MatType> asRef(Eigen::Ref<MatType> mat) {
template
<
typename
MatType
>
const
Eigen
::
Ref
<
const
MatType
>
asConstRef
(
Eigen
::
Ref
<
const
MatType
>
mat
)
{
std
::
cout
<<
"create const Ref to input
\n
"
;
return
Eigen
::
Ref
<
const
MatType
>
(
mat
);
}
...
...
This diff is collapsed.
Click to expand it.
unittest/python/test_eigen_ref.py
+
31
−
31
View file @
99b35dea
...
...
@@ -17,10 +17,14 @@ def test_fill_print(mat):
printMatrix
(
mat
)
print
(
"
calling fill():
"
)
fill
(
mat
,
1.0
)
print
(
"
print again:
"
)
printMatrix
(
mat
)
assert
np
.
array_equal
(
mat
,
np
.
full
(
mat
.
shape
,
1.0
))
print
(
"
fill a slice
"
)
mat
[:,
:]
=
0.0
fill
(
mat
[:
3
,
:
2
],
1.0
)
printMatrix
(
mat
[:
3
,
:
2
])
assert
np
.
array_equal
(
mat
[:
3
,
:
2
],
np
.
ones
((
3
,
2
)))
def
test_create_ref_to_static
(
mat
):
# create ref to static:
...
...
@@ -40,53 +44,46 @@ def test_create_ref_to_static(mat):
def
test_create_ref
(
mat
):
# create ref to input:
print
(
"
[asRef(mat)]
"
)
ref
=
asRef
(
mat
)
assert
np
.
array_equal
(
ref
,
mat
)
assert
np
.
array_equal
(
ref
,
mat
)
,
"
ref=
\n
{}
\n
mat=
\n
{}
"
.
format
(
ref
,
mat
)
assert
not
(
ref
.
flags
.
owndata
)
assert
ref
.
flags
.
writeable
def
test_create_const_ref
(
mat
):
print
(
"
[asConstRef]
"
)
const_ref
=
asConstRef
(
mat
)
print
(
const_ref
.
flags
)
assert
np
.
array_equal
(
const_ref
,
mat
)
assert
np
.
array_equal
(
const_ref
,
mat
),
"
ref=
\n
{}
\n
mat=
\n
{}
"
.
format
(
const_ref
,
mat
)
assert
not
(
const_ref
.
flags
.
writeable
)
assert
not
(
const_ref
.
flags
.
owndata
)
print
(
"
fill a slice
"
)
mat
[:,
:]
=
0.0
fill
(
mat
[:
3
,
:
2
],
1.0
)
assert
np
.
array_equal
(
mat
[:
3
,
:
2
],
np
.
ones
((
3
,
2
)))
mat
[:,
:]
=
0.0
fill
(
mat
[:
2
,
:
3
],
1.0
)
assert
np
.
array_equal
(
mat
[:
2
,
:
3
],
np
.
ones
((
2
,
3
)))
def
test_edit_block
(
rows
,
cols
):
print
(
"
set mat data to arange()
"
)
mat
.
fill
(
0.0
)
mat
[:,
:]
=
np
.
arange
(
rows
*
cols
).
reshape
(
rows
,
cols
)
mat0
=
mat
.
copy
()
mat_as_C_order
=
np
.
array
(
mat
,
order
=
"
F
"
)
for
i
,
rowsize
,
colsize
in
([
0
,
3
,
2
],
[
1
,
1
,
2
],
[
0
,
3
,
1
]):
print
(
"
taking block [{}:{}, {}:{}]
"
.
format
(
i
,
rowsize
+
i
,
0
,
colsize
))
B
=
getBlock
(
mat_as_C_order
,
i
,
0
,
rowsize
,
colsize
)
lhs
=
mat_as_C_order
[
i
:
rowsize
+
i
,
:
colsize
]
assert
np
.
array_equal
(
lhs
,
B
.
reshape
(
rowsize
,
colsize
))
B
=
getBlock
(
mat
,
i
,
0
,
rowsize
,
colsize
)
B
=
B
.
reshape
(
rowsize
,
colsize
)
lhs
=
mat
[
i
:
rowsize
+
i
,
:
colsize
]
assert
np
.
array_equal
(
lhs
,
B
),
"
got lhs
\n
{}
\n
rhs B=
\n
{}
"
.
format
(
lhs
,
B
)
B
[:]
=
1.0
rhs
=
np
.
ones
((
rowsize
,
colsize
))
assert
np
.
array_equal
(
mat
_as_C_order
[
i
:
rowsize
+
i
,
:
colsize
],
rhs
)
assert
np
.
array_equal
(
mat
[
i
:
rowsize
+
i
,
:
colsize
],
rhs
)
mat
_as_C_order
[:,
:]
=
mat0
mat
[:,
:]
=
mat0
mat_copy
=
mat_as_C_order
.
copy
()
mat
.
fill
(
0.0
)
mat_copy
=
mat
.
copy
()
print
(
"
[editBlock]
"
)
editBlock
(
mat
_as_C_order
,
0
,
0
,
3
,
2
)
editBlock
(
mat
,
0
,
0
,
3
,
2
)
mat_copy
[:
3
,
:
2
]
=
np
.
arange
(
6
).
reshape
(
3
,
2
)
assert
np
.
array_equal
(
mat
_as_C_order
,
mat_copy
)
assert
np
.
array_equal
(
mat
,
mat_copy
)
class
ModifyBlockImpl
(
modify_block
):
def
__init__
(
self
):
...
...
@@ -112,10 +109,13 @@ def test_create_ref(mat):
assert
np
.
array_equal
(
hasref
.
J
,
J_true
)
def
_
do_test
(
mat
):
def
do_test
(
mat
):
test_fill_print
(
mat
)
test_create_ref_to_static
(
mat
)
test_create_const_ref
(
mat
)
test_create_ref
(
mat
)
test_edit_block
(
rows
,
cols
)
print
(
"
=
"
*
10
)
if
__name__
==
"
__main__
"
:
...
...
@@ -125,10 +125,10 @@ if __name__ == "__main__":
mat
=
np
.
ones
((
rows
,
cols
),
order
=
"
F
"
)
mat
[
0
,
0
]
=
0
mat
[
1
:
5
,
1
:
5
]
=
6
_
do_test
(
mat
)
do_test
(
mat
)
mat
=
np
.
ones
((
rows
,
cols
))
mat
[
2
:
4
,
1
:
4
]
=
2
_do_test
(
mat
)
mat
_f
=
np
.
asfortranarray
(
mat
)
_
do_test
(
mat
_f
)
#
mat
2
= np.ones((rows, cols))
#
mat
2[:2, :5
] =
0.
# mat2[2:4, 1:4] = 2
#
mat
2[:, -1] = 3
#
do_test(mat
2
)
This diff is collapsed.
Click to expand it.
unittest/python/test_std_vector.py
+
12
−
12
View file @
99b35dea
...
...
@@ -9,9 +9,9 @@ np.random.seed(0)
l1
=
[
np
.
random
.
randn
(
3
),
np
.
random
.
randn
(
2
)]
l2
=
eigenpy
.
StdVec_VectorXd
(
l1
)
l3
=
[
np
.
random
.
randn
(
2
,
2
)
.
T
,
np
.
random
.
randn
(
3
,
1
)]
l3
.
append
(
np
.
eye
(
2
,
order
=
"
F
"
))
l3
.
append
(
np
.
eye
(
2
,
order
=
"
C
"
))
l3
=
[
np
.
random
.
randn
(
2
,
2
),
np
.
random
.
randn
(
3
,
1
)]
l3
.
append
(
np
.
asfortranarray
(
np
.
eye
(
2
)
))
l3
.
append
(
np
.
eye
(
2
))
l4
=
[
np
.
random
.
randn
(
3
,
3
).
T
for
_
in
range
(
3
)]
l4
[
-
1
]
=
l4
[
-
1
].
T
...
...
@@ -73,13 +73,13 @@ pprint.pp(list(l3_copy))
checkZero
(
l3_copy
)
print
(
"
-----------------
"
)
print
(
"
l3:
"
)
vector
.
setZero
(
l3
)
pprint
.
pp
(
list
(
l3
))
checkZero
(
l3
)
print
(
"
-----------------
"
)
#
print("l3
_python
:")
#
vector.setZero(l3)
#
pprint.pp
rint
(list(l3))
#
checkZero(l3)
#
print("-----------------")
print
(
"
l4:
"
)
vector
.
setZero
(
l4
)
pprint
.
pp
(
list
(
l4
))
checkZero
(
l4
)
#
print("l4:")
#
vector.setZero(l4)
#
pprint.pp
rint
(list(l4))
#
checkZero(l4)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment