From 6e8a41ea872d94cbd0196f14b28d224e53b5c83c Mon Sep 17 00:00:00 2001 From: hrocho Date: Wed, 15 May 2019 17:12:06 +0200 Subject: [PATCH] info fix --- pymodule/pycatima.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/pymodule/pycatima.cpp b/pymodule/pycatima.cpp index 8f6132e..3446a55 100644 --- a/pymodule/pycatima.cpp +++ b/pymodule/pycatima.cpp @@ -18,24 +18,29 @@ void catima_info(){ printf("max energy point = 10^%lf MeV/u\n",logEmax); } +std::string material_to_string(const Material &r){ + std::string s; + auto n = r.ncomponents(); + for(int i = 0; i < n; i++){ + auto el = r.get_element(i); + s += "#"+std::to_string(i); + s += ": A = "+std::to_string(el.A) + ", Z = "+std::to_string(el.A)+ ", stn = "+std::to_string(el.stn)+"\n"; + } + return s; + }; + py::list storage_info(){ py::list res; for(int i=0; i0 && data.p.Z && data.m.ncomponents()>0){ py::list mat; - for(int j=0; j(&Material::I, py::const_), "get I") .def("I",py::overload_cast(&Material::I), "set I") - .def("__str__",[](const Material &r){ - std::string s; - auto n = r.ncomponents(); - for(int i = 0; i < n; i++){ - auto el = r.get_element(i); - s += "#"+std::to_string(i); - s += ": A = "+std::to_string(el.A) + ", Z = "+std::to_string(el.A)+ ", stn = "+std::to_string(el.stn)+"\n"; - } - return s; - }); + .def("__str__",&material_to_string); py::class_(m,"Layers") .def(py::init<>(),"constructor")