diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-10-11 14:40:48 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-10-11 14:40:48 +0200 |
commit | a2adf6a90246110fcae4e6a6dcc049d8d69fcb48 (patch) | |
tree | ec94d9e77e067e2e168467947f5fd390ed66c569 /lib/utils.py | |
parent | 2a75bc679e2970f9ae938a418af5acea9106e61d (diff) |
add helper functions for co-dependent parameter detection
Diffstat (limited to 'lib/utils.py')
-rw-r--r-- | lib/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/utils.py b/lib/utils.py index e5699da..f040638 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -114,6 +114,21 @@ def param_slice_eq(a, b, index): return True return False +def match_parameter_values(input_param: dict, match_param: dict): + """ + Check whether one of the paramaters in `input_param` has the same value in `match_param`. + + :param input_param: parameter dict of a state/transition/... measurement + :param match_param: parameter value filter + :returns: True if for all parameters k in match_param: input_param[k] == match_param[k], or if match_param is None. + """ + if match_param is None: + return True + for k, v in match_param.items(): + if k in input_param and input_param[k] != v: + return False + return True + def by_name_to_by_param(by_name: dict): """ Convert aggregation by name to aggregation by name and parameter values. @@ -132,6 +147,8 @@ def by_name_to_by_param(by_name: dict): by_param[param_key]['isa'] = by_name[name]['isa'] for attribute in by_name[name]['attributes']: by_param[param_key][attribute].append(by_name[name][attribute][i]) + # Required for match_parameter_valuse in _try_fits + by_param[param_key]['param'].append(by_name[name]['param'][i]) return by_param def filter_aggregate_by_param(aggregate, parameters, parameter_filter): |