コード例 #1
0
 def test_load_dft_json_file(self):
     dft = stormpy.dft.load_dft_json_file(
         get_example_path("dft", "and.json"))
     assert dft.nr_elements() == 3
     assert dft.nr_be() == 2
     assert dft.nr_dynamic() == 0
     assert not dft.can_have_nondeterminism()
コード例 #2
0
 def test_load_dft_galileo_file(self):
     dft = stormpy.dft.load_dft_galileo_file(
         get_example_path("dft", "hecs.dft"))
     assert dft.nr_elements() == 23
     assert dft.nr_be() == 13
     assert dft.nr_dynamic() == 2
     assert not dft.can_have_nondeterminism()
コード例 #3
0
ファイル: test_dft.py プロジェクト: moves-rwth/stormpy
 def test_modularisation(self):
     dft = stormpy.dft.load_dft_galileo_file(
         get_example_path("dft", "hecs.dft"))
     assert dft.nr_elements() == 23
     assert dft.nr_be() == 13
     assert dft.nr_dynamic() == 2
     dfts = dft.modularisation()
     assert len(dfts) == 4
     for ft in dfts:
         assert ft.top_level_element.name in ["n116", "n137", "n120", "n21"]
コード例 #4
0
 def test_export_dft_json_string(self):
     dft = stormpy.dft.load_dft_galileo_file(
         get_example_path("dft", "hecs.dft"))
     assert dft.nr_elements() == 23
     assert dft.nr_be() == 13
     assert dft.nr_dynamic() == 2
     json_string = stormpy.dft.export_dft_json_string(dft)
     dft2 = stormpy.dft.load_dft_json_string(json_string)
     assert dft2.nr_elements() == 23
     assert dft2.nr_be() == 13
     assert dft2.nr_dynamic() == 2
コード例 #5
0
 def test_export_dft_json_file(self, tmpdir):
     dft = stormpy.dft.load_dft_galileo_file(
         get_example_path("dft", "hecs.dft"))
     assert dft.nr_elements() == 23
     assert dft.nr_be() == 13
     assert dft.nr_dynamic() == 2
     export_file = os.path.join(str(tmpdir), "hecs.json")
     stormpy.dft.export_dft_json_file(dft, export_file)
     dft2 = stormpy.dft.load_dft_json_file(export_file)
     assert dft2.nr_elements() == 23
     assert dft2.nr_be() == 13
     assert dft2.nr_dynamic() == 2
コード例 #6
0
 def test_load_dft_json_string(self):
     # Build json string
     json_node_a = '{"data": {"id":"0", "name":"A", "type":"be", "rate":"1", "dorm":"1", "label":"A (1)"}, "group":"nodes", "classes":"be"}'
     json_node_b = '{"data": {"id":"1", "name":"B", "type":"be", "rate":"1", "dorm":"1", "label":"B (1)"}, "group":"nodes", "classes":"be"}'
     json_node_c = '{"data": {"id":"6", "name":"Z", "type":"pand", "children":["0", "1"], "label":"Z"}, "group":"nodes", "classes":"pand"}'
     json_string = '{"toplevel": "6", "parameters": {}, "nodes": [' + json_node_a + ',' + json_node_b + ',' + json_node_c + ']}'
     # Load
     dft = stormpy.dft.load_dft_json_string(json_string)
     assert dft.nr_elements() == 3
     assert dft.nr_be() == 2
     assert dft.nr_dynamic() == 1
     assert not dft.can_have_nondeterminism()
コード例 #7
0
ファイル: test_dft.py プロジェクト: moves-rwth/stormpy
 def test_parametric_dft(self):
     import pycarl
     pycarl.clear_pools()
     dft = stormpy.dft.load_parametric_dft_galileo_file(
         get_example_path("dft", "symmetry_param.dft"))
     assert dft.nr_elements() == 7
     assert dft.nr_be() == 4
     assert dft.nr_dynamic() == 0
     assert type(dft) is stormpy.dft.DFT_ratfunc
     parameters = stormpy.dft.get_parameters(dft)
     param_names = [x.name for x in parameters]
     assert "x" in param_names
     assert "y" in param_names
コード例 #8
0
ファイル: test_dft.py プロジェクト: moves-rwth/stormpy
 def test_element(self):
     dft = stormpy.dft.load_dft_json_file(
         get_example_path("dft", "and.json"))
     tle = dft.top_level_element
     assert dft.nr_elements() == 3
     assert dft.nr_be() == 2
     assert dft.nr_dynamic() == 0
     assert tle.id == 2
     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)