diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-12-18 17:19:54 +0100 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-12-18 17:19:54 +0100 |
commit | d46afd5dfc4e41b8a22d2531d89d02dc377e5ad9 (patch) | |
tree | 34852a876f3ec5700b6721e2c47c6646006ae041 | |
parent | 342468318abd2004a2f01105fb0c9c0507c62211 (diff) |
PTA: Load state power functions from YAML if available
-rwxr-xr-x | lib/automata.py | 6 |
1 files changed, 5 insertions, 1 deletions
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] |