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
ee3370b1
Commit
ee3370b1
authored
Apr 19, 2022
by
pre-commit-ci[bot]
Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see
https://pre-commit.ci
parent
c29edd71
Pipeline
#18389
failed with stage
in 1 minute and 52 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
unittest/eigen_ref.cpp
View file @
ee3370b1
...
...
@@ -52,27 +52,18 @@ const Eigen::Ref<const MatType> asConstRef(Eigen::Ref<MatType> mat) {
return
Eigen
::
Ref
<
const
MatType
>
(
mat
);
}
struct
modify_block
{
struct
modify_block
{
MatrixXd
J
;
modify_block
()
:
J
(
10
,
10
)
{
J
.
setZero
();
}
void
modify
(
int
n
,
int
m
)
{
call
(
J
.
topLeftCorner
(
n
,
m
));
}
void
modify
(
int
n
,
int
m
)
{
call
(
J
.
topLeftCorner
(
n
,
m
));
}
virtual
void
call
(
Eigen
::
Ref
<
MatrixXd
>
mat
)
=
0
;
};
struct
modify_wrap
:
modify_block
,
bp
::
wrapper
<
modify_block
>
{
struct
modify_wrap
:
modify_block
,
bp
::
wrapper
<
modify_block
>
{
modify_wrap
()
:
modify_block
()
{}
void
call
(
Eigen
::
Ref
<
MatrixXd
>
mat
)
{
this
->
get_override
(
"call"
)(
mat
);
}
void
call
(
Eigen
::
Ref
<
MatrixXd
>
mat
)
{
this
->
get_override
(
"call"
)(
mat
);
}
};
BOOST_PYTHON_MODULE
(
eigen_ref
)
{
namespace
bp
=
boost
::
python
;
eigenpy
::
enableEigenPy
();
...
...
@@ -100,9 +91,7 @@ BOOST_PYTHON_MODULE(eigen_ref) {
Eigen
::
Ref
<
MatrixXd
>
))
asConstRef
<
MatrixXd
>
);
bp
::
class_
<
modify_wrap
,
boost
::
noncopyable
>
(
"modify_block"
,
bp
::
init
<>
())
.
def_readonly
(
"J"
,
&
modify_block
::
J
)
.
def
(
"modify"
,
&
modify_block
::
modify
)
.
def
(
"call"
,
bp
::
pure_virtual
(
&
modify_wrap
::
call
))
;
.
def_readonly
(
"J"
,
&
modify_block
::
J
)
.
def
(
"modify"
,
&
modify_block
::
modify
)
.
def
(
"call"
,
bp
::
pure_virtual
(
&
modify_wrap
::
call
));
}
unittest/python/test_eigen_ref.py
View file @
ee3370b1
...
...
@@ -29,18 +29,18 @@ def test(mat):
super
().
__init__
()
def
call
(
self
,
mat
):
mat
[:,
:]
=
1.
mat
[:,
:]
=
1.
0
modify
=
ModifyBlockImpl
()
print
(
"Field J init:
\n
{}"
.
format
(
modify
.
J
))
modify
.
modify
(
2
,
3
)
print
(
"Field J after:
\n
{}"
.
format
(
modify
.
J
))
Jref
=
np
.
zeros
((
10
,
10
))
Jref
[:
2
,
:
3
]
=
1.
Jref
[:
2
,
:
3
]
=
1.
0
print
(
"Should be:
\n
{}"
.
format
(
Jref
))
assert
np
.
array_equal
(
Jref
,
modify
.
J
)
rows
=
10
cols
=
30
...
...
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