From 7a2265e1503118012118a39fdb76c1cbf30f8918 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Thu, 20 Jun 2024 14:38:39 +0100 Subject: [PATCH 1/5] lisa.analysis.rta: Add missing pandas DataFrame index name FIX --- lisa/analysis/rta.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lisa/analysis/rta.py b/lisa/analysis/rta.py index fc70e31a1..428e63a05 100644 --- a/lisa/analysis/rta.py +++ b/lisa/analysis/rta.py @@ -322,6 +322,7 @@ class RTAEventsAnalysis(TraceAnalysisBase): .reset_index() .set_index([col for col in kept_cols if col != 'properties']) ) + df.index.name = 'phases' return df -- GitLab From ba3d046dec89cc2818620718335068f941fe65a6 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Thu, 20 Jun 2024 14:40:34 +0100 Subject: [PATCH 2/5] lisa.analysis.base: Fix pandas index inference FIX Only infer the index for polars types, as a pandas type already has a known index. --- lisa/analysis/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisa/analysis/base.py b/lisa/analysis/base.py index c2bfc1777..802ab228b 100644 --- a/lisa/analysis/base.py +++ b/lisa/analysis/base.py @@ -1196,7 +1196,7 @@ class TraceAnalysisBase(AnalysisHelpers): fmt=df_fmt, index=( ('Time' if 'Time' in df.columns else None) - if index is None else + if index is None and isinstance(df, (pl.LazyFrame, pl.DataFrame)) else index ), ) -- GitLab From 1797d9b18cf73f0092384a4950f221687ea6d08d Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Thu, 20 Jun 2024 14:46:36 +0100 Subject: [PATCH 3/5] lisa.analysis.tasks: Handle correct exception in get_task_ids() FIX Handle KeyError rather than IndexError. --- lisa/analysis/tasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisa/analysis/tasks.py b/lisa/analysis/tasks.py index ca4468063..44399533e 100644 --- a/lisa/analysis/tasks.py +++ b/lisa/analysis/tasks.py @@ -427,7 +427,7 @@ class TasksAnalysis(TraceAnalysisBase): def comm_to_pid(comm): try: pid_list = self._task_name_map[comm] - except IndexError: + except KeyError: # pylint: disable=raise-missing-from raise ValueError(f'trace does not have any task named "{comm}"') @@ -436,7 +436,7 @@ class TasksAnalysis(TraceAnalysisBase): def pid_to_comm(pid): try: comm_list = self._task_pid_map[pid] - except IndexError: + except KeyError: # pylint: disable=raise-missing-from raise ValueError(f'trace does not have any task PID {pid}') -- GitLab From 32cb95b984062d88dabfc997a19770032452b593 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Thu, 20 Jun 2024 15:03:04 +0100 Subject: [PATCH 4/5] lisa.trace: Ensure Trace.window has a (Timestamp, Timestamp) type FIX Ensure we have the expected types for Trace.window. --- lisa/trace.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lisa/trace.py b/lisa/trace.py index 91956daf6..82ddcc239 100644 --- a/lisa/trace.py +++ b/lisa/trace.py @@ -3205,7 +3205,21 @@ class _WindowTraceView(_TraceViewBase): compress_signals_init=None, ): super().__init__(trace) - self._window = window + + def fixup_window(window): + if window: + start, end = window + if start is not None: + start = Timestamp(start, rounding='down') + + if end is not None: + end = Timestamp(end, rounding='up') + + return (start, end) + else: + return None + + self._window = fixup_window(window) self._signals = set(signals or []) self._compress_signals_init = compress_signals_init -- GitLab From d0961ca772fd8f43185760683ed3995579bb9120 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Thu, 20 Jun 2024 15:08:07 +0100 Subject: [PATCH 5/5] lisa.tests.base: Iterate over Categorical Series rather than .apply() FIX Series.apply() on a categorical dtype leads to pandas executing the applied function on values that appear in the category but not necessarily in the actual data. This can raise unexpectedly, e.g. on trace slices where the a comm only appears outside the slice. --- lisa/tests/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lisa/tests/base.py b/lisa/tests/base.py index fb34b7a58..e3b97f9e9 100644 --- a/lisa/tests/base.py +++ b/lisa/tests/base.py @@ -1793,7 +1793,10 @@ class RTATestBundle(FtraceTestBundle, DmesgTestBundle): # Find out which task(s) this threshold is about if isinstance(key, str): comms = df.loc[df['comm'].str.match(key), 'comm'] - task_ids = comms.apply(self.trace.ana.tasks.get_task_id) + task_ids = [ + self.trace.ana.tasks.get_task_id(comm) + for comm in comms + ] else: # Use update=False to let None fields propagate, as they are # used to indicate a "dont care" value -- GitLab