fix(python-bindings): Updated python bindings to new interface

The python bindings now work with the polymorphic reaction class and the CVODE solver
This commit is contained in:
2025-10-30 15:05:08 -04:00
parent 23df87f915
commit 7fded59814
27 changed files with 962 additions and 255 deletions

View File

@@ -1,6 +1,7 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h> // Needed for vectors, maps, sets, strings
#include <pybind11/stl_bind.h> // Needed for binding std::vector, std::map etc. if needed directly
#include <format>
#include "bindings.h"
@@ -32,12 +33,18 @@ void register_type_bindings(const pybind11::module &m) {
.def_readonly("composition", &gridfire::NetOut::composition)
.def_readonly("num_steps", &gridfire::NetOut::num_steps)
.def_readonly("energy", &gridfire::NetOut::energy)
.def_readonly("dEps_dT", &gridfire::NetOut::dEps_dT)
.def_readonly("dEps_dRho", &gridfire::NetOut::dEps_dRho)
.def("__repr__", [](const gridfire::NetOut &netOut) {
std::stringstream ss;
ss << "NetOut(composition=" << netOut.composition
<< ", num_steps=" << netOut.num_steps
<< ", energy=" << netOut.energy << ")";
return ss.str();
std::string repr = std::format(
"NetOut(<μ> = {} steps = {}, ε = {}, dε/dT = {}, dε/dρ = {})",
netOut.composition.getMeanParticleMass(),
netOut.num_steps,
netOut.energy,
netOut.dEps_dT,
netOut.dEps_dRho
);
return repr;
});
}