summaryrefslogtreecommitdiff
path: root/lib/cli.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-11-01 10:07:55 +0100
committerDaniel Friesel <daniel.friesel@uos.de>2021-11-01 10:07:55 +0100
commit49c2c463ff6b454c944af3b023139ad4448c8ce4 (patch)
treed90d2e07be933a749dcae58a3769a664ac0aeaa5 /lib/cli.py
parentf1a0129b36d9abb96669d08e09ea4b958bc99b54 (diff)
move model quality table to dfatool.cli; add quality output to analyze-kconfig
Diffstat (limited to 'lib/cli.py')
-rw-r--r--lib/cli.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/cli.py b/lib/cli.py
index 6c6419c..2972ca5 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -1,5 +1,11 @@
#!/usr/bin/env python3
+from dfatool.functions import (
+ SplitFunction,
+ AnalyticFunction,
+ StaticFunction,
+)
+
def print_static(model, static_model, name, attribute):
unit = " "
@@ -25,3 +31,48 @@ def print_static(model, static_model, name, attribute):
model.attr_by_name[name][attribute].stats.param_dependence_ratio(param),
)
)
+
+
+def format_quality_measures(result):
+ if "smape" in result:
+ return "{:6.2f}% / {:9.0f}".format(result["smape"], result["mae"])
+ else:
+ return "{:6} {:9.0f}".format("", result["mae"])
+
+
+def model_quality_table(header, result_lists, info_list):
+ print(
+ "{:20s} {:15s} {:19s} {:19s} {:19s}".format(
+ "key",
+ "attribute",
+ header[0].center(19),
+ header[1].center(19),
+ header[2].center(19),
+ )
+ )
+ for state_or_tran in result_lists[0].keys():
+ for key in result_lists[0][state_or_tran].keys():
+ buf = "{:20s} {:15s}".format(state_or_tran, key)
+ for i, results in enumerate(result_lists):
+ info = info_list[i]
+ buf += " ||| "
+ if (
+ info is None
+ or (
+ key != "energy_Pt"
+ and type(info(state_or_tran, key)) is not StaticFunction
+ )
+ or (
+ key == "energy_Pt"
+ and (
+ type(info(state_or_tran, "power")) is not StaticFunction
+ or type(info(state_or_tran, "duration"))
+ is not StaticFunction
+ )
+ )
+ ):
+ result = results[state_or_tran][key]
+ buf += format_quality_measures(result)
+ else:
+ buf += "{:7}----{:8}".format("", "")
+ print(buf)