Browse Source

Default arguments for StateValuationsBuilder.add_state()

refactoring
Matthias Volk 5 years ago
parent
commit
ab06826b80
No known key found for this signature in database GPG Key ID: 83A57678F739FCD3
  1. 4
      src/storage/valuation.cpp
  2. 4
      tests/storage/test_model_components.py

4
src/storage/valuation.cpp

@ -10,7 +10,7 @@ std::string toJson(storm::storage::sparse::StateValuations const& valuations, st
return valuations.toJson(stateIndex, selectedVariables).dump(); return valuations.toJson(stateIndex, selectedVariables).dump();
} }
void add_state(storm::storage::sparse::StateValuationsBuilder& builder, storm::storage::sparse::state_type const& state, std::vector<bool>&& booleanValues = {}, std::vector<int64_t>&& integerValues = {}, std::vector<storm::RationalNumber>&& rationalValues = {}) {
void add_state(storm::storage::sparse::StateValuationsBuilder& builder, storm::storage::sparse::state_type const& state, std::vector<bool>&& booleanValues, std::vector<int64_t>&& integerValues, std::vector<storm::RationalNumber>&& rationalValues) {
return builder.addState(state, std::move(booleanValues), std::move(integerValues), std::move(rationalValues)); return builder.addState(state, std::move(booleanValues), std::move(integerValues), std::move(rationalValues));
} }
@ -31,7 +31,7 @@ void define_statevaluation(py::module& m) {
py::class_<storm::storage::sparse::StateValuationsBuilder, std::shared_ptr<storm::storage::sparse::StateValuationsBuilder>>(m,"StateValuationsBuilder") py::class_<storm::storage::sparse::StateValuationsBuilder, std::shared_ptr<storm::storage::sparse::StateValuationsBuilder>>(m,"StateValuationsBuilder")
.def(py::init<>()) .def(py::init<>())
.def("add_variable", &storm::storage::sparse::StateValuationsBuilder::addVariable, py::arg("variable"), "Adds a new variable") .def("add_variable", &storm::storage::sparse::StateValuationsBuilder::addVariable, py::arg("variable"), "Adds a new variable")
.def("add_state", &add_state,py::arg("state"),py::arg("boolean_values"), py::arg("integer_values"), py::arg("rational_values"), "Adds a new state, no more variables should be added afterwards")
.def("add_state", &add_state, py::arg("state"), py::arg("boolean_values") = std::vector<bool>(), py::arg("integer_values") = std::vector<int64_t>(), py::arg("rational_values") = std::vector<storm::RationalNumber>(), "Adds a new state, no more variables should be added afterwards")
.def("build", &storm::storage::sparse::StateValuationsBuilder::build, "Creates the finalized state valuations object") .def("build", &storm::storage::sparse::StateValuationsBuilder::build, "Creates the finalized state valuations object")
; ;

4
tests/storage/test_model_components.py

@ -76,9 +76,9 @@ class TestSparseModelComponents:
for s in range(7): for s in range(7):
v_builder.add_state(state=s,boolean_values=[],integer_values=[s,0],rational_values=[])
v_builder.add_state(state=s,integer_values=[s,0])
for s in range(7,13): for s in range(7,13):
v_builder.add_state(state=s,boolean_values=[],integer_values=[7,s-6],rational_values=[])
v_builder.add_state(state=s,integer_values=[7,s-6])
state_valuations = v_builder.build(13) state_valuations = v_builder.build(13)

Loading…
Cancel
Save