From 5a28b0c9fe86558379deaceee184d0aa67540763 Mon Sep 17 00:00:00 2001 From: Alexandre Nobuharu Sato <66435071+AlexandreSato@users.noreply.github.com> Date: Mon, 24 Mar 2025 18:40:25 -0300 Subject: [PATCH] Avoid IndexError in max_lat_accel.py due to empty values in dataset (#34926) * Update max_lat_accel.py The error you're encountering is due to the fact that the code is trying to calculate the 90th percentile of lateral acceleration values that are less than 0, but there are no such values in the dataset. This results in an empty list, which causes the np.percentile function to fail with an IndexError * fix * simpler --------- Co-authored-by: Shane Smiskol --- selfdrive/debug/max_lat_accel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/selfdrive/debug/max_lat_accel.py b/selfdrive/debug/max_lat_accel.py index 889a855356..d562e5d3f3 100755 --- a/selfdrive/debug/max_lat_accel.py +++ b/selfdrive/debug/max_lat_accel.py @@ -97,8 +97,8 @@ if __name__ == '__main__': print() print(f'Found {len(events)} events') - perc_left_accel = -np.percentile([-ev.lateral_accel for ev in events if ev.lateral_accel < 0], 90) - perc_right_accel = np.percentile([ev.lateral_accel for ev in events if ev.lateral_accel > 0], 90) + perc_left_accel = -np.percentile([-ev.lateral_accel for ev in events if ev.lateral_accel < 0] or [0], 90) + perc_right_accel = np.percentile([ev.lateral_accel for ev in events if ev.lateral_accel > 0] or [0], 90) CP = lr.first('carParams')