From c5724cc3988b064730de57a04e72a9168455bc12 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 8 Mar 2021 14:41:16 +0100 Subject: model.assess: remove superfluous "by_name" indirection --- bin/analyze-archive.py | 18 +++++++++--------- bin/analyze-timing.py | 6 +++--- bin/eval-outlier-removal.py | 11 +++++------ bin/eval-rel-energy.py | 4 ++-- bin/test_corrcoef.py | 6 +++--- 5 files changed, 22 insertions(+), 23 deletions(-) (limited to 'bin') diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py index e7027ed..582302d 100755 --- a/bin/analyze-archive.py +++ b/bin/analyze-archive.py @@ -91,8 +91,8 @@ def model_quality_table(header, result_lists, info_list): header[2].center(19), ) ) - for state_or_tran in result_lists[0]["by_name"].keys(): - for key in result_lists[0]["by_name"][state_or_tran].keys(): + 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] @@ -112,7 +112,7 @@ def model_quality_table(header, result_lists, info_list): ) ) ): - result = results["by_name"][state_or_tran][key] + result = results[state_or_tran][key] buf += format_quality_measures(result) else: buf += "{:7}----{:8}".format("", "") @@ -226,12 +226,12 @@ def print_html_model_data(raw_data, model, pm, pq, lm, lq, am, ai, aq): unit = "" if attribute == "power": unit = "µW" - static_quality = pq["by_name"][state][attribute]["smape"] + static_quality = pq[state][attribute]["smape"] print( f"* {attribute} mean: {pm(state, attribute):.0f} {unit} (± {static_quality:.1f}%)" ) if ai(state, attribute): - analytic_quality = aq["by_name"][state][attribute]["smape"] + analytic_quality = aq[state][attribute]["smape"] fstr = ai(state, attribute)["function"].model_function fstr = fstr.replace("0 + ", "", 1) for i, marg in enumerate(ai(state, attribute)["function"].model_args): @@ -261,12 +261,12 @@ def print_html_model_data(raw_data, model, pm, pq, lm, lq, am, ai, aq): unit = "µs" elif attribute in ["energy", "rel_energy_prev"]: unit = "pJ" - static_quality = pq["by_name"][trans][attribute]["smape"] + static_quality = pq[trans][attribute]["smape"] print( f"* {attribute} mean: {pm(trans, attribute):.0f} {unit} (± {static_quality:.1f}%)" ) if ai(trans, attribute): - analytic_quality = aq["by_name"][trans][attribute]["smape"] + analytic_quality = aq[trans][attribute]["smape"] fstr = ai(trans, attribute)["function"].model_function fstr = fstr.replace("0 + ", "", 1) for i, marg in enumerate(ai(trans, attribute)["function"].model_args): @@ -288,7 +288,7 @@ def print_html_model_data(raw_data, model, pm, pq, lm, lq, am, ai, aq): unit = "µW" print( "{:.0f} {} ({:.1f}%)".format( - pm(state, attribute), unit, pq["by_name"][state][attribute]["smape"] + pm(state, attribute), unit, pq[state][attribute]["smape"] ), end="", ) @@ -315,7 +315,7 @@ def print_html_model_data(raw_data, model, pm, pq, lm, lq, am, ai, aq): unit = "pJ" print( "{:.0f} {} ({:.1f}%)".format( - pm(trans, attribute), unit, pq["by_name"][trans][attribute]["smape"] + pm(trans, attribute), unit, pq[trans][attribute]["smape"] ), end="", ) diff --git a/bin/analyze-timing.py b/bin/analyze-timing.py index e8af0fb..129b0ff 100755 --- a/bin/analyze-timing.py +++ b/bin/analyze-timing.py @@ -111,14 +111,14 @@ def format_quality_measures(result): def model_quality_table(result_lists, info_list): - for state_or_tran in result_lists[0]["by_name"].keys(): - for key in result_lists[0]["by_name"][state_or_tran].keys(): + 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 type(info(state_or_tran, key)) is not StaticFunction: - result = results["by_name"][state_or_tran][key] + result = results[state_or_tran][key] buf += format_quality_measures(result) else: buf += "{:6}----{:9}".format("", "") diff --git a/bin/eval-outlier-removal.py b/bin/eval-outlier-removal.py index d6c905c..217d43f 100755 --- a/bin/eval-outlier-removal.py +++ b/bin/eval-outlier-removal.py @@ -10,11 +10,11 @@ opt = dict() def model_quality_table(result_lists, info_list): - for state_or_tran in result_lists[0]["by_name"].keys(): - for key in result_lists[0]["by_name"][state_or_tran].keys(): + 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): - results = results["by_name"] + results = results info = info_list[i] buf += " ||| " if info == None or info(state_or_tran, key): @@ -31,12 +31,11 @@ def model_quality_table(result_lists, info_list): def combo_model_quality_table(result_lists, info_list): - for state_or_tran in result_lists[0][0]["by_name"].keys(): - for key in result_lists[0][0]["by_name"][state_or_tran].keys(): + for state_or_tran in result_lists[0][0].keys(): + for key in result_lists[0][0][state_or_tran].keys(): for sub_result_lists in result_lists: buf = "{:20s} {:15s}".format(state_or_tran, key) for i, results in enumerate(sub_result_lists): - results = results["by_name"] info = info_list[i] buf += " ||| " if info == None or info(state_or_tran, key): diff --git a/bin/eval-rel-energy.py b/bin/eval-rel-energy.py index cec1576..245746a 100755 --- a/bin/eval-rel-energy.py +++ b/bin/eval-rel-energy.py @@ -92,8 +92,8 @@ if __name__ == "__main__": lut_quality = model.assess(model.get_param_lut()) for trans in model.transitions: - absolute_quality = lut_quality["by_name"][trans]["energy"] - relative_quality = lut_quality["by_name"][trans]["rel_energy_prev"] + absolute_quality = lut_quality[trans]["energy"] + relative_quality = lut_quality[trans]["rel_energy_prev"] if absolute_quality["mae"] < relative_quality["mae"]: best = "absolute" score_absolute += 1 diff --git a/bin/test_corrcoef.py b/bin/test_corrcoef.py index 49944cd..2e21890 100755 --- a/bin/test_corrcoef.py +++ b/bin/test_corrcoef.py @@ -33,14 +33,14 @@ def format_quality_measures(result): def model_quality_table(result_lists, info_list): - for state_or_tran in result_lists[0]["by_name"].keys(): - for key in result_lists[0]["by_name"][state_or_tran].keys(): + 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 == None or info(state_or_tran, key): - result = results["by_name"][state_or_tran][key] + result = results[state_or_tran][key] buf += format_quality_measures(result) else: buf += "{:6}----{:9}".format("", "") -- cgit v1.2.3