summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBirte Kristina Friesel <birte.friesel@uos.de>2023-12-21 10:28:23 +0100
committerBirte Kristina Friesel <birte.friesel@uos.de>2023-12-21 10:28:23 +0100
commita9f3b859b7a7d702285b51113d901108fee31a62 (patch)
tree97df2492ddbc0ef05eb1fd65952514e10425659d
parent10e6561615be67a775993ec5bfbd54eac2efa9a1 (diff)
analyze-kconfig: add --boxplot-(un)param and --non-interactive support
-rwxr-xr-xbin/analyze-kconfig.py70
-rwxr-xr-xbin/analyze-log.py3
-rw-r--r--lib/cli.py3
3 files changed, 70 insertions, 6 deletions
diff --git a/bin/analyze-kconfig.py b/bin/analyze-kconfig.py
index a7049f6..a1a8e6a 100755
--- a/bin/analyze-kconfig.py
+++ b/bin/analyze-kconfig.py
@@ -19,6 +19,7 @@ import time
import numpy as np
import dfatool.cli
+import dfatool.plotter
import dfatool.utils
from dfatool.loader.kconfig import KConfigAttributes
from dfatool.model import AnalyticModel
@@ -373,9 +374,72 @@ def main():
if args.export_pgf_unparam:
dfatool.cli.export_pgf_unparam(model, args.export_pgf_unparam)
- if args.plot_param:
- from dfatool import plotter
+ if args.boxplot_unparam:
+ title = None
+ if args.filter_param:
+ title = "filter: " + ", ".join(
+ map(lambda kv: f"{kv[0]}={kv[1]}", args.filter_param)
+ )
+ for name in model.names:
+ attr_names = sorted(model.attributes(name))
+ dfatool.plotter.boxplot(
+ attr_names,
+ [model.by_name[name][attr] for attr in attr_names],
+ xlabel="Attribute",
+ output=f"{args.boxplot_unparam}{name}.pdf",
+ title=title,
+ show=not args.non_interactive,
+ )
+ for attribute in attr_names:
+ dfatool.plotter.boxplot(
+ [attribute],
+ [model.by_name[name][attribute]],
+ output=f"{args.boxplot_unparam}{name}-{attribute}.pdf",
+ title=title,
+ show=not args.non_interactive,
+ )
+ if args.boxplot_param:
+ 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,
+ )
+
+ if args.plot_param:
for kv in args.plot_param.split(";"):
try:
state_or_trans, attribute, param_name, *function = kv.split(":")
@@ -389,7 +453,7 @@ def main():
function = gplearn_to_function(" ".join(function))
else:
function = None
- plotter.plot_param(
+ dfatool.plotter.plot_param(
model,
state_or_trans,
attribute,
diff --git a/bin/analyze-log.py b/bin/analyze-log.py
index e3cd7aa..d639b5e 100755
--- a/bin/analyze-log.py
+++ b/bin/analyze-log.py
@@ -78,9 +78,6 @@ def main():
"--export-model", metavar="FILE", type=str, help="Export JSON model to FILE"
)
parser.add_argument(
- "--non-interactive", action="store_true", help="Do not show interactive plots"
- )
- parser.add_argument(
"logfiles",
nargs="+",
type=str,
diff --git a/lib/cli.py b/lib/cli.py
index a0ba51c..b33bd4a 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -303,6 +303,9 @@ def add_standard_arguments(parser):
help="Export boxplots of observations to {PREFIX}{name}-{attribute}.pdf, with one boxplot per parameter combination",
)
parser.add_argument(
+ "--non-interactive", action="store_true", help="Do not show interactive plots"
+ )
+ parser.add_argument(
"--export-xv",
metavar="FILE",
type=str,