From 3c57a67ac6e7fd03532b6274118940f29621a0bc Mon Sep 17 00:00:00 2001 From: ATATC Date: Fri, 4 Oct 2024 19:10:28 -0400 Subject: [PATCH] Simplified `speed_trend()`. (#433) --- leads/context.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/leads/context.py b/leads/context.py index d04f921..80effba 100644 --- a/leads/context.py +++ b/leads/context.py @@ -3,8 +3,6 @@ from time import time as _time from typing import TypeVar as _TypeVar, Generic as _Generic -from numpy import diff as _diff, average as _average, array as _array - from leads.constant import ESCMode from leads.data import DataContainer @@ -83,7 +81,7 @@ def lap_times(self) -> list[int]: return [self._lap_time_seq[i] - self._lap_time_seq[i - 1] for i in range(1, len(self._lap_time_seq))] def speed_trend(self) -> float: - return float(_average(_diff(_array(self._speed_seq)))) if len(self._speed_seq) > 1 else 0 + return (self._speed_seq[-1] - self._speed_seq[0]) / len(self._speed_seq) if len(self._speed_seq) > 1 else 0 def brake_indicator(self, brake_indicator: bool | None = None) -> bool | None: if brake_indicator is None: