From 0e218eb84950085405d47329a3b7e8bc8e167788 Mon Sep 17 00:00:00 2001 From: Simon Mazenoux <simon.mazenoux@cern.ch> Date: Mon, 9 Sep 2024 09:42:58 +0200 Subject: [PATCH] use list comprehension for summary output --- lhcsmapi/api/analysis/output/qh/_common.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lhcsmapi/api/analysis/output/qh/_common.py b/lhcsmapi/api/analysis/output/qh/_common.py index a51c451..22fa124 100644 --- a/lhcsmapi/api/analysis/output/qh/_common.py +++ b/lhcsmapi/api/analysis/output/qh/_common.py @@ -16,21 +16,16 @@ SUMMARY_TABLE_ID = "Table" def get_summary_output(events: list[qh.Event], results: list[qh.Result]) -> list[output_types.Output]: - list_result = [] - - for event, result in zip(events, results): - list_result.append( - [ - event.source, - Time.Time.to_string_short(event.timestamp), - event.circuit_type, - event.circuit_name, - "PASSED" if result.is_qh_ok else "FAILED", - ] - ) df_result = pd.DataFrame( - list_result, columns=["source", "datetime", "circuit_type", "circuit_name", "analysis_result"] + { + "source": event.source, + "datetime": Time.Time.to_string_short(event.timestamp), + "circuit_type": event.circuit_type, + "circuit_name": event.circuit_name, + "analysis_result": "PASSED" if result.is_qh_ok else "FAILED", + } + for event, result in zip(events, results) ) df_result["datetime"] = df_result["datetime"].astype("datetime64[ms]") # RQs are in ns whereas other circuits in ms return [output_types.HTMLOutput(df_result.to_html())] -- GitLab