From 2a66c7c7ee5f7c0b4c7120755f0a0072b284986d Mon Sep 17 00:00:00 2001 From: Christopher Usher Date: Wed, 13 Nov 2024 11:24:51 -0800 Subject: [PATCH] Fix to handle cases where there are no good odometer readings --- thrimshim/thrimshim/bus_stats.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/thrimshim/thrimshim/bus_stats.py b/thrimshim/thrimshim/bus_stats.py index bfebda3..282dd28 100644 --- a/thrimshim/thrimshim/bus_stats.py +++ b/thrimshim/thrimshim/bus_stats.py @@ -37,6 +37,10 @@ def post_process_miles(seconds, miles, days): continue good.append(i) + # if there are no 'good' odometer readings, bail on post processing + if len(good) == 0: + return [math.nan for i in range(len(miles))] + corrected_miles = [miles[i] if i in good else 0. for i in range(len(miles))] # identify groups of suspicious data and correct them for k, g in itertools.groupby(enumerate(suspect), lambda x:x[0]-x[1]):