diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2023-12-22 07:37:13 +0100 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2023-12-22 07:37:13 +0100 |
commit | 745a94e664b7dd820d4c96e37396aa04b59d5242 (patch) | |
tree | df45eb9adef1bec82e4d6e319a74cbc751094b0e /lib/cli.py | |
parent | 56c0d44f78f40cbc64f889dcbc2ff282a37bc3b0 (diff) |
move --boxplot-param implementation to cli.py
Diffstat (limited to 'lib/cli.py')
-rw-r--r-- | lib/cli.py | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -6,6 +6,7 @@ from dfatool.functions import ( StaticFunction, FOLFunction, ) +import dfatool.plotter import logging import numpy as np @@ -269,6 +270,46 @@ def export_json_unparam(model, filename): logger.info(f"JSON unparam data saved to {filename}") +def boxplot_param(args, model): + title = None + param_is_filtered = dict() + if args.filter_param: + title = "filter: " + ", ".join( + map(lambda kv: f"{kv[0]}={kv[1]}", args.filter_param) + ) + for param_name, _ in args.filter_param: + param_is_filtered[param_name] = True + by_param = model.get_by_param() + for name in model.names: + attr_names = sorted(model.attributes(name)) + param_keys = list( + map(lambda kv: kv[1], filter(lambda kv: kv[0] == name, by_param.keys())) + ) + param_desc = list( + map( + lambda param_key: ", ".join( + map( + lambda ip: f"{model.param_name(ip[0])}={ip[1]}", + filter( + lambda ip: model.param_name(ip[0]) not in param_is_filtered, + enumerate(param_key), + ), + ) + ), + param_keys, + ) + ) + for attribute in attr_names: + dfatool.plotter.boxplot( + param_desc, + list(map(lambda k: by_param[(name, k)][attribute], param_keys)), + output=f"{args.boxplot_param}{name}-{attribute}.pdf", + title=title, + ylabel=attribute, + show=not args.non_interactive, + ) + + def add_standard_arguments(parser): parser.add_argument( "--export-dot", |