Commit ee3370b1 authored by pre-commit-ci[bot]'s avatar 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
......@@ -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));
}
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment