From d46afd5dfc4e41b8a22d2531d89d02dc377e5ad9 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 18 Dec 2019 17:19:54 +0100 Subject: PTA: Load state power functions from YAML if available --- lib/automata.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/automata.py b/lib/automata.py index 552b482..d977164 100755 --- a/lib/automata.py +++ b/lib/automata.py @@ -102,7 +102,7 @@ class PTAAttribute: @classmethod def from_json_maybe(cls, json_wrapped: dict, attribute: str, parameters: dict): - if attribute in json_wrapped: + if type(json_wrapped) is dict and attribute in json_wrapped: return cls.from_json(json_wrapped[attribute], parameters) return cls() @@ -653,6 +653,10 @@ class PTA: pta = cls(**kwargs) + if 'state' in yaml_input: + for state_name, state in yaml_input['state'].items(): + pta.add_state(state_name, power=PTAAttribute.from_json_maybe(state, 'power', pta.parameters)) + for trans_name in sorted(yaml_input['transition'].keys()): kwargs = dict() transition = yaml_input['transition'][trans_name] -- cgit v1.2.3