summaryrefslogtreecommitdiff
path: root/lib/utils.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2022-09-23 12:54:59 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2022-09-23 12:54:59 +0200
commit8d96626746a00eaea7fcf3c45229022910c74470 (patch)
treee11e52ae364d647fca93f80bd46fbe5e4135aac3 /lib/utils.py
parent553bb7d218ffa2b7214423388f3b33c72b469418 (diff)
ignore_param: work on by_name rather than observations
Diffstat (limited to 'lib/utils.py')
-rw-r--r--lib/utils.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/lib/utils.py b/lib/utils.py
index 9914862..f81f8ff 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -302,14 +302,26 @@ def observations_enum_to_bool(observations: list, kconfig=False):
binary_keys.add(binary_key)
-def observations_ignore_param(observations: list, ignored_parameters: list) -> list:
- unpoppable_params = set()
- for observation in observations:
- for ignored_parameter in ignored_parameters:
- try:
- observation["param"].pop(ignored_parameter)
- except KeyError:
- unpoppable_params.add(ignored_parameter)
+def ignore_param(by_name: dict, parameter_names: list, ignored_parameters: list):
+ ignored_indexes = list()
+ unpoppable_params = list()
+ for param_name in sorted(ignored_parameters):
+ try:
+ ignored_indexes.append(parameter_names.index(param_name))
+ except ValueError:
+ unpoppable_params.append(param_name)
+
+ assert ignored_indexes == sorted(ignored_indexes)
+ ignored_indexes = sorted(ignored_indexes, reverse=True)
+
+ for name in by_name:
+ for param in by_name[name]["param"]:
+ for ignored_index in ignored_indexes:
+ param.pop(ignored_index)
+
+ for ignored_index in ignored_indexes:
+ parameter_names.pop(ignored_index)
+
if unpoppable_params:
logger.info(
f"ignore_param: Parameters {unpoppable_params} were not part of the observations to begin with"