Browse Source

Get DFT elements by name

refactoring
Matthias Volk 4 years ago
parent
commit
27a97f313d
No known key found for this signature in database GPG Key ID: 83A57678F739FCD3
  1. 6
      src/dft/dft.cpp
  2. 11
      tests/dft/test_dft.py

6
src/dft/dft.cpp

@ -43,6 +43,9 @@ void define_dft(py::module& m) {
return dft.getElement(dft.getTopLevelIndex()); return dft.getElement(dft.getTopLevelIndex());
}, "Get top level element") }, "Get top level element")
.def("get_element", &DFT<double>::getElement, "Get DFT element at index", py::arg("index")) .def("get_element", &DFT<double>::getElement, "Get DFT element at index", py::arg("index"))
.def("get_element_by_name", [](DFT<double>& dft, std::string const& name) {
return dft.getElement(dft.getIndex(name));
}, "Get DFT element by name", py::arg("name"))
.def("modularisation", &DFT<double>::topModularisation, "Split DFT into independent modules") .def("modularisation", &DFT<double>::topModularisation, "Split DFT into independent modules")
.def("symmetries", [](DFT<double>& dft) { .def("symmetries", [](DFT<double>& dft) {
return dft.findSymmetries(dft.colourDFT()); return dft.findSymmetries(dft.colourDFT());
@ -59,6 +62,9 @@ void define_dft(py::module& m) {
return dft.getElement(dft.getTopLevelIndex()); return dft.getElement(dft.getTopLevelIndex());
}, "Get top level element") }, "Get top level element")
.def("get_element", &DFT<storm::RationalFunction>::getElement, "Get DFT element at index", py::arg("index")) .def("get_element", &DFT<storm::RationalFunction>::getElement, "Get DFT element at index", py::arg("index"))
.def("get_element_by_name", [](DFT<storm::RationalFunction>& dft, std::string const& name) {
return dft.getElement(dft.getIndex(name));
}, "Get DFT element by name", py::arg("name"))
.def("modularisation", &DFT<storm::RationalFunction>::topModularisation, "Split DFT into independent modules") .def("modularisation", &DFT<storm::RationalFunction>::topModularisation, "Split DFT into independent modules")
.def("symmetries", [](DFT<storm::RationalFunction>& dft) { .def("symmetries", [](DFT<storm::RationalFunction>& dft) {
return dft.findSymmetries(dft.colourDFT()); return dft.findSymmetries(dft.colourDFT());

11
tests/dft/test_dft.py

@ -1,4 +1,5 @@
import os import os
import pytest
import stormpy import stormpy
import stormpy.logic import stormpy.logic
@ -30,6 +31,16 @@ class TestDftElement:
assert dft.nr_dynamic() == 0 assert dft.nr_dynamic() == 0
assert tle.id == 2 assert tle.id == 2
assert tle.name == "A" assert tle.name == "A"
b = dft.get_element(0)
assert b.id == 0
assert b.name == "B"
c = dft.get_element_by_name("C")
assert c.id == 1
assert c.name == "C"
# Invalid name should raise exception
with pytest.raises(RuntimeError) as exception:
d = dft.get_element_by_name("D")
assert "InvalidArgumentException" in str(exception.value)
@dft @dft
class TestDftSymmetries: class TestDftSymmetries:

Loading…
Cancel
Save