Browse Source

Refactored documentation examples according to PEP

refactoring
Matthias Volk 7 years ago
parent
commit
12b934267e
  1. 2
      examples/01-getting-started.py
  2. 4
      examples/02-getting-started.py
  3. 3
      examples/03-getting-started.py
  4. 3
      examples/04-getting-started.py

2
examples/01-getting-started.py

@ -4,6 +4,7 @@ import stormpy.core
import stormpy.examples import stormpy.examples
import stormpy.examples.files import stormpy.examples.files
def example_getting_started_01(): def example_getting_started_01():
path = stormpy.examples.files.prism_dtmc_die path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path) prism_program = stormpy.parse_prism_program(path)
@ -13,5 +14,6 @@ def example_getting_started_01():
print("Number of transitions: {}".format(model.nr_transitions)) print("Number of transitions: {}".format(model.nr_transitions))
print("Labels: {}".format(model.labeling.get_labels())) print("Labels: {}".format(model.labeling.get_labels()))
if __name__ == '__main__': if __name__ == '__main__':
example_getting_started_01() example_getting_started_01()

4
examples/02-getting-started.py

@ -4,11 +4,11 @@ import stormpy.core
import stormpy.examples import stormpy.examples
import stormpy.examples.files import stormpy.examples.files
def example_getting_started_02(): def example_getting_started_02():
path = stormpy.examples.files.prism_dtmc_die path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path) prism_program = stormpy.parse_prism_program(path)
model = stormpy.build_model(prism_program) model = stormpy.build_model(prism_program)
print("Number of states: {}".format(model.nr_states)) print("Number of states: {}".format(model.nr_states))
print("Number of transitions: {}".format(model.nr_transitions)) print("Number of transitions: {}".format(model.nr_transitions))
@ -21,7 +21,6 @@ def example_getting_started_02():
print("Number of transitions: {}".format(model_for_formula.nr_transitions)) print("Number of transitions: {}".format(model_for_formula.nr_transitions))
print("Labels in the model: {}".format(model_for_formula.labeling.get_labels())) print("Labels in the model: {}".format(model_for_formula.labeling.get_labels()))
formula_str_2 = "P=? [F s=7 & d=2]" formula_str_2 = "P=? [F s=7 & d=2]"
properties_2 = stormpy.parse_properties_for_prism_program(formula_str_2, prism_program) properties_2 = stormpy.parse_properties_for_prism_program(formula_str_2, prism_program)
model_for_formula_2 = stormpy.build_model(prism_program, properties_2) model_for_formula_2 = stormpy.build_model(prism_program, properties_2)
@ -29,5 +28,6 @@ def example_getting_started_02():
print("Number of transitions: {}".format(model_for_formula_2.nr_transitions)) print("Number of transitions: {}".format(model_for_formula_2.nr_transitions))
print("Labels in the model: {}".format(model_for_formula_2.labeling.get_labels())) print("Labels in the model: {}".format(model_for_formula_2.labeling.get_labels()))
if __name__ == '__main__': if __name__ == '__main__':
example_getting_started_02() example_getting_started_02()

3
examples/03-getting-started.py

@ -4,11 +4,11 @@ import stormpy.core
import stormpy.examples import stormpy.examples
import stormpy.examples.files import stormpy.examples.files
def example_getting_started_03(): def example_getting_started_03():
path = stormpy.examples.files.prism_dtmc_die path = stormpy.examples.files.prism_dtmc_die
prism_program = stormpy.parse_prism_program(path) prism_program = stormpy.parse_prism_program(path)
formula_str = "P=? [F s=7 & d=2]" formula_str = "P=? [F s=7 & d=2]"
properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program) properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program)
model = stormpy.build_model(prism_program, properties) model = stormpy.build_model(prism_program, properties)
@ -20,5 +20,6 @@ def example_getting_started_03():
initial_state = model.initial_states[0] initial_state = model.initial_states[0]
print(result.at(initial_state)) print(result.at(initial_state))
if __name__ == '__main__': if __name__ == '__main__':
example_getting_started_03() example_getting_started_03()

3
examples/04-getting-started.py

@ -8,11 +8,11 @@ import pycarl.core
import stormpy.examples import stormpy.examples
import stormpy.examples.files import stormpy.examples.files
def example_getting_started_04(): def example_getting_started_04():
path = stormpy.examples.files.prism_pdtmc_die path = stormpy.examples.files.prism_pdtmc_die
prism_program = stormpy.parse_prism_program(path) prism_program = stormpy.parse_prism_program(path)
formula_str = "P=? [F s=7 & d=2]" formula_str = "P=? [F s=7 & d=2]"
properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program) properties = stormpy.parse_properties_for_prism_program(formula_str, prism_program)
model = stormpy.build_parametric_model(prism_program, properties) model = stormpy.build_parametric_model(prism_program, properties)
@ -29,5 +29,6 @@ def example_getting_started_04():
result = stormpy.model_checking(instantiated_model, properties[0]) result = stormpy.model_checking(instantiated_model, properties[0])
print(result) print(result)
if __name__ == '__main__': if __name__ == '__main__':
example_getting_started_04() example_getting_started_04()
Loading…
Cancel
Save