aboutsummaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2020-05-25 07:38:40 +0200
committerTibor Frank <tifrank@cisco.com>2020-05-25 10:29:18 +0200
commitdd41e6e33cec88898593b5fdc3064113d2cc3a81 (patch)
treeb0a65bf9bca975f6d8cf68593dfb08fb715a76fb /resources
parent216073ac4b05619d9e9fc73131075597196af753 (diff)
Trending: Sorting in weekly comparison
Change-Id: I4e143a1f108f1c6975b24d2355bdac9f2a74ab46 Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources')
-rw-r--r--resources/tools/presentation/generator_tables.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/resources/tools/presentation/generator_tables.py b/resources/tools/presentation/generator_tables.py
index 0986cfe159..d128a11e54 100644
--- a/resources/tools/presentation/generator_tables.py
+++ b/resources/tools/presentation/generator_tables.py
@@ -1932,12 +1932,13 @@ def table_weekly_comparison(table, in_data):
ref_data = tst_data.get(idx_ref, None)
cmp_data = tst_data.get(idx_cmp, None)
if ref_data is None or cmp_data is None:
- cmp_dict[tst_name].append(float('nan'))
+ cmp_dict[tst_name].append(float(u'nan'))
else:
cmp_dict[tst_name].append(
relative_change(ref_data, cmp_data)
)
+ tbl_lst_none = list()
tbl_lst = list()
for tst_name, tst_data in tbl_dict.items():
itm_lst = [tst_data[u"name"], ]
@@ -1953,13 +1954,19 @@ def table_weekly_comparison(table, in_data):
for itm in cmp_dict[tst_name]
]
)
- tbl_lst.append(itm_lst)
+ if str(itm_lst[-1]) == u"nan" or itm_lst[-1] is None:
+ tbl_lst_none.append(itm_lst)
+ else:
+ tbl_lst.append(itm_lst)
+ tbl_lst_none.sort(key=lambda rel: rel[0], reverse=False)
tbl_lst.sort(key=lambda rel: rel[0], reverse=False)
- tbl_lst.sort(key=lambda rel: rel[-1], reverse=True)
+ tbl_lst.sort(key=lambda rel: rel[-1], reverse=False)
+ tbl_lst.extend(tbl_lst_none)
# Generate csv table:
csv_file = f"{table[u'output-file']}.csv"
+ logging.info(f" Writing the file {csv_file}")
with open(csv_file, u"wt", encoding='utf-8') as file_handler:
for hdr in header:
file_handler.write(u",".join(hdr) + u"\n")
@@ -1972,6 +1979,7 @@ def table_weekly_comparison(table, in_data):
) + u"\n")
txt_file = f"{table[u'output-file']}.txt"
+ logging.info(f" Writing the file {txt_file}")
convert_csv_to_pretty_txt(csv_file, txt_file, delimiter=u",")
# Reorganize header in txt table