Skip to content

Commit

Permalink
Additional bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
volkm committed Dec 19, 2023
1 parent d146a9a commit e30bfc5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/stormpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,11 +602,11 @@ def parse_properties(properties, context=None, filters=None):
if context.is_prism_program():
return core.parse_properties_for_prism_program(properties, context.as_prism_program(), filters)
else:
core.parse_properties_for_jani_program(properties, context.as_jani_model(), filters)
return core.parse_properties_for_jani_program(properties, context.as_jani_model(), filters)
elif type(context) == storage.PrismProgram:
return core.parse_properties_for_prism_program(properties, context, filters)
elif type(context) == storage.JaniModel:
core.parse_properties_for_jani_model(properties, context, filters)
return core.parse_properties_for_jani_model(properties, context, filters)
else:
raise StormError("Unclear context. Please pass a symbolic model description")

Expand Down
5 changes: 4 additions & 1 deletion src/storage/bitvector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void define_bitvector(py::module& m) {
.def("set", [](BitVector& b, uint_fast64_t i, bool v) {
b.set(i, v);
}, py::arg("index"), py::arg("value") = true, "Set")
.def("as_int", &BitVector::getAsInt, py::arg("index"), py::arg("no_bits"), "Get as unsigned int")

.def("__len__", [](BitVector const& b) { return b.size(); })
.def("__getitem__", [](BitVector const& b, uint_fast64_t i) {
Expand Down Expand Up @@ -49,7 +50,9 @@ void define_bitvector(py::module& m) {
.def(py::self |= py::self)

.def("__str__", &streamToString<BitVector>)

.def("__hash__", [](const BitVector &b) {
return storm::storage::Murmur3BitVectorHash<uint64_t>()(b);
})
;

}
1 change: 1 addition & 0 deletions src/storage/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ void define_sparse_model(py::module& m, std::string const& vtSuffix) {
.def("labels_state", &SparseModel<ValueType>::getLabelsOfState, py::arg("state"), "Get labels of state")
.def_property_readonly("initial_states", &getSparseInitialStates<ValueType>, "Initial states")
.def_property_readonly("initial_states_as_bitvector", [](SparseModel<ValueType> const& model) {return model.getInitialStates();})
.def("set_initial_states", &SparseModel<ValueType>::setInitialStates, py::arg("states"), "Set initial states")
.def_property_readonly("states", [](SparseModel<ValueType>& model) {
return SparseModelStates<ValueType>(model);
}, "Get states")
Expand Down

0 comments on commit e30bfc5

Please sign in to comment.