From e68df0a428113305f7dbedf1fbac35d3565b5b20 Mon Sep 17 00:00:00 2001 From: hrocho Date: Sun, 20 Jun 2021 12:48:40 +0200 Subject: [PATCH] repr --- pymodule/pycatima.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pymodule/pycatima.cpp b/pymodule/pycatima.cpp index a8db7a6..f5db64a 100644 --- a/pymodule/pycatima.cpp +++ b/pymodule/pycatima.cpp @@ -175,7 +175,10 @@ PYBIND11_MODULE(pycatima,m){ .def_readwrite("sigma_x", &Result::sigma_x) .def_readwrite("tof", &Result::tof) .def_readwrite("sp", &Result::sp) - .def("get_dict",&get_result_dict); + .def("get_dict",&get_result_dict) + .def("__repr__",[](const Result &self){ + return py::str(get_result_dict(self)); + }); py::class_(m,"MultiResult") .def(py::init<>(),"constructor") @@ -211,7 +214,17 @@ PYBIND11_MODULE(pycatima,m){ } d["partial"] = p; return d; - }); + }) + .def("__repr__",[](const MultiResult &r){ + py::dict d; + py::list p; + d["result"] = get_result_dict(r.total_result); + for(auto& entry:r.results){ + p.append(get_result_dict(entry)); + } + d["partial"] = p; + return py::str(d); + }); py::enum_(m,"z_eff_type") .value("none", z_eff_type::none)