From 086ad8cd9bcc2e89a8bfb0c33bb0a2f4060fc245 Mon Sep 17 00:00:00 2001 From: Ishaan Desai Date: Fri, 13 Oct 2023 16:01:21 -0400 Subject: [PATCH] Fix C++ solver dummy --- examples/cpp-dummy/micro_cpp_dummy.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/examples/cpp-dummy/micro_cpp_dummy.cpp b/examples/cpp-dummy/micro_cpp_dummy.cpp index 5d271561..dd0b6863 100644 --- a/examples/cpp-dummy/micro_cpp_dummy.cpp +++ b/examples/cpp-dummy/micro_cpp_dummy.cpp @@ -47,15 +47,14 @@ py::dict MicroSimulation::solve(py::dict macro_data, double dt) // This function needs to set the complete state of a micro simulation void MicroSimulation::set_state(py::list state) { - _sim_id = state[0].cast() - _micro_scalar_data = state[1].cast(); - _state = state[2].cast(); + _micro_scalar_data = state[0].cast(); + _state = state[1].cast(); } // This function needs to return variables which can fully define the state of a micro simulation py::list MicroSimulation::get_state() const { - std::vector state{_sim_id, _micro_scalar_data, _state}; + std::vector state{_micro_scalar_data, _state}; py::list state_python = py::cast(state); return state_python; } @@ -65,7 +64,7 @@ PYBIND11_MODULE(micro_dummy, m) { m.doc() = "pybind11 micro dummy plugin"; py::class_(m, "MicroSimulation") - .def(py::init()) + .def(py::init()) .def("solve", &MicroSimulation::solve) .def("get_state", &MicroSimulation::get_state) .def("set_state", &MicroSimulation::set_state) @@ -74,7 +73,7 @@ PYBIND11_MODULE(micro_dummy, m) { return ms.get_state(); }, [](py::list t) { // __setstate__ - if (t.size() != 3) + if (t.size() != 2) throw std::runtime_error("Invalid state!"); /* Create a new C++ instance */