Merging 'master' into 'wrap'
commit
f13ffc482c
|
@ -75,7 +75,17 @@ class PybindWrapper(object):
|
||||||
[]({class_inst} self, string serialized){{
|
[]({class_inst} self, string serialized){{
|
||||||
gtsam::deserialize(serialized, *self);
|
gtsam::deserialize(serialized, *self);
|
||||||
}}, py::arg("serialized"))
|
}}, py::arg("serialized"))
|
||||||
'''.format(class_inst=cpp_class + '*'))
|
.def(py::pickle(
|
||||||
|
[](const {cpp_class} &a){{ // __getstate__
|
||||||
|
/* Returns a string that encodes the state of the object */
|
||||||
|
return py::make_tuple(gtsam::serialize(a));
|
||||||
|
}},
|
||||||
|
[](py::tuple t){{ // __setstate__
|
||||||
|
{cpp_class} obj;
|
||||||
|
gtsam::deserialize(t[0].cast<std::string>(), obj);
|
||||||
|
return obj;
|
||||||
|
}}))
|
||||||
|
'''.format(class_inst=cpp_class + '*', cpp_class=cpp_class))
|
||||||
|
|
||||||
is_method = isinstance(method, instantiator.InstantiatedMethod)
|
is_method = isinstance(method, instantiator.InstantiatedMethod)
|
||||||
is_static = isinstance(method, parser.StaticMethod)
|
is_static = isinstance(method, parser.StaticMethod)
|
||||||
|
@ -318,3 +328,4 @@ class PybindWrapper(object):
|
||||||
wrapped_namespace=wrapped_namespace,
|
wrapped_namespace=wrapped_namespace,
|
||||||
boost_class_export=boost_class_export,
|
boost_class_export=boost_class_export,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,16 @@ PYBIND11_MODULE(geometry_py, m_) {
|
||||||
[](gtsam::Point2* self, string serialized){
|
[](gtsam::Point2* self, string serialized){
|
||||||
gtsam::deserialize(serialized, *self);
|
gtsam::deserialize(serialized, *self);
|
||||||
}, py::arg("serialized"))
|
}, py::arg("serialized"))
|
||||||
|
.def(py::pickle(
|
||||||
|
[](const gtsam::Point2 &a){ // __getstate__
|
||||||
|
/* Returns a string that encodes the state of the object */
|
||||||
|
return py::make_tuple(gtsam::serialize(a));
|
||||||
|
},
|
||||||
|
[](py::tuple t){ // __setstate__
|
||||||
|
gtsam::Point2 obj;
|
||||||
|
gtsam::deserialize(t[0].cast<std::string>(), obj);
|
||||||
|
return obj;
|
||||||
|
}))
|
||||||
;
|
;
|
||||||
|
|
||||||
py::class_<gtsam::Point3, std::shared_ptr<gtsam::Point3>>(m_gtsam, "Point3")
|
py::class_<gtsam::Point3, std::shared_ptr<gtsam::Point3>>(m_gtsam, "Point3")
|
||||||
|
@ -61,6 +71,16 @@ PYBIND11_MODULE(geometry_py, m_) {
|
||||||
[](gtsam::Point3* self, string serialized){
|
[](gtsam::Point3* self, string serialized){
|
||||||
gtsam::deserialize(serialized, *self);
|
gtsam::deserialize(serialized, *self);
|
||||||
}, py::arg("serialized"))
|
}, py::arg("serialized"))
|
||||||
|
.def(py::pickle(
|
||||||
|
[](const gtsam::Point3 &a){ // __getstate__
|
||||||
|
/* Returns a string that encodes the state of the object */
|
||||||
|
return py::make_tuple(gtsam::serialize(a));
|
||||||
|
},
|
||||||
|
[](py::tuple t){ // __setstate__
|
||||||
|
gtsam::Point3 obj;
|
||||||
|
gtsam::deserialize(t[0].cast<std::string>(), obj);
|
||||||
|
return obj;
|
||||||
|
}))
|
||||||
|
|
||||||
.def_static("staticFunction",[](){return gtsam::Point3::staticFunction();})
|
.def_static("staticFunction",[](){return gtsam::Point3::staticFunction();})
|
||||||
.def_static("StaticFunctionRet",[]( double z){return gtsam::Point3::StaticFunctionRet(z);}, py::arg("z"));
|
.def_static("StaticFunctionRet",[]( double z){return gtsam::Point3::StaticFunctionRet(z);}, py::arg("z"));
|
||||||
|
|
Loading…
Reference in New Issue