Make SummaryState::set() available as __setitem__ in Python

This commit is contained in:
Joakim Hove
2022-01-28 09:26:01 +01:00
parent c660b2e4b4
commit c37c2b2d49
2 changed files with 5 additions and 2 deletions

View File

@@ -75,8 +75,10 @@ public:
explicit SummaryState(std::time_t sim_start_arg);
/*
The set() function has to be retained temporarily to support updating of
cumulatives from restart files.
The canonical way to update the SummaryState is through the update_xxx()
methods which will inspect the variable and either accumulate or just
assign, depending on whether it represents a total or not. The set()
method is low level and unconditionally do an assignment.
*/
void set(const std::string& key, double value);

View File

@@ -55,5 +55,6 @@ void python::common::export_SummaryState(py::module& module) {
.def("__contains__", &SummaryState::has)
.def("has_well_var", py::overload_cast<const std::string&, const std::string&>(&SummaryState::has_well_var, py::const_))
.def("has_group_var", py::overload_cast<const std::string&, const std::string&>(&SummaryState::has_group_var, py::const_))
.def("__setitem__", &SummaryState::set)
.def("__getitem__", py::overload_cast<const std::string&>(&SummaryState::get, py::const_));
}