diff --git a/python/py_aka_parser.cc b/python/py_aka_parser.cc index e49650376..83131a7b4 100644 --- a/python/py_aka_parser.cc +++ b/python/py_aka_parser.cc @@ -1,69 +1,72 @@ /* -------------------------------------------------------------------------- */ #include "py_aka_array.hh" /* -------------------------------------------------------------------------- */ #include #include #include #include /* -------------------------------------------------------------------------- */ #include #include #include #include /* -------------------------------------------------------------------------- */ namespace py = pybind11; /* -------------------------------------------------------------------------- */ namespace akantu { std::map> map_params; __attribute__((visibility("default"))) void register_parser(py::module & mod) { py::enum_(mod, "ParameterAccessType", py::arithmetic()) .value("_pat_internal", _pat_internal) .value("_pat_writable", _pat_writable) .value("_pat_readable", _pat_readable) .value("_pat_modifiable", _pat_modifiable) .value("_pat_parsable", _pat_parsable) .value("_pat_parsmod", _pat_parsmod) .export_values(); py::class_(mod, "ParameterRegistry", py::multiple_inheritance()) .def("registerParamReal", [](ParameterRegistry & self, const std::string & name, UInt type, const std::string & description) { Real * p = new Real; map_params[&self][name] = p; self.registerParam(name, *p, ParameterAccessType(type), description); }) .def("registerParamReal", [](ParameterRegistry & self, const Real & _default, const std::string & name, UInt type, const std::string & description) { Real * p = new Real; map_params[&self][name] = p; self.registerParam(name, *p, _default, ParameterAccessType(type), description); }) .def("getReal", [](ParameterRegistry & self, const std::string & name) { return Real(self.get(name)); }) - .def("getMatrix", [](ParameterRegistry & self, const std::string & name) { - Matrix res = self.get(name); - return res; - }); + .def("getMatrix", + [](ParameterRegistry & self, const std::string & name) { + const Matrix & res = + static_cast &>(self.get(name)); + return res; + }, + py::return_value_policy::copy); py::class_(mod, "Parsable", py::multiple_inheritance()) .def(py::init()); mod.def("parseInput", [](const std::string & input_file) { getStaticParser().parse(input_file); }, "Parse an Akantu input file"); } } // namespace akantu