summaryrefslogtreecommitdiff
path: root/lib/automata.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2019-09-25 14:41:06 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2019-09-25 14:41:06 +0200
commit35724ec75c281fc758963db69a1e112d53de687a (patch)
tree2559b233a90da4eed3b05bd7375b73acfdec2ac9 /lib/automata.py
parent73d595de982145f27d94ed5711aab65f844d87ab (diff)
PTA: handle None in parameter value normalization
Diffstat (limited to 'lib/automata.py')
-rwxr-xr-xlib/automata.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/automata.py b/lib/automata.py
index ca78723..1715841 100755
--- a/lib/automata.py
+++ b/lib/automata.py
@@ -346,17 +346,21 @@ class PTA:
if 'formula' in normalization_spec:
normalization_spec['formula'] = NormalizationFunction(normalization_spec['formula'])
+ def normalize_parameter(self, parameter_name, parameter_value):
+ if parameter_value is not None and self.parameter_normalization is not None and parameter_name in self.parameter_normalization:
+ if 'enum' in self.parameter_normalization[parameter_name] and parameter_value in self.parameter_normalization[parameter_name]['enum']:
+ return self.parameter_normalization[parameter_name]['enum'][parameter_value]
+ if 'formula' in self.parameter_normalization[parameter_name]:
+ normalization_formula = self.parameter_normalization[parameter_name]['formula']
+ return normalization_formula.eval(parameter_value)
+ return parameter_value
+
def normalize_parameters(self, param_dict):
if self.parameter_normalization is None:
return param_dict.copy()
normalized_param = param_dict.copy()
for parameter, value in param_dict.items():
- if parameter in self.parameter_normalization:
- if 'enum' in self.parameter_normalization[parameter] and value in self.parameter_normalization[parameter]['enum']:
- normalized_param[parameter] = self.parameter_normalization[parameter]['enum'][value]
- if 'formula' in self.parameter_normalization[parameter]:
- normalization_formula = self.parameter_normalization[parameter]['formula']
- normalized_param[parameter] = normalization_formula.eval(value)
+ normalized_param[parameter] = self.normalize_parameter(parameter, value)
return normalized_param
@classmethod