From 745a94e664b7dd820d4c96e37396aa04b59d5242 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Fri, 22 Dec 2023 07:37:13 +0100 Subject: move --boxplot-param implementation to cli.py --- lib/cli.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'lib') diff --git a/lib/cli.py b/lib/cli.py index 41bbe6a..5c57278 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -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", -- cgit v1.2.3