Skip to content

Commit

Permalink
Simplified speed_trend(). (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
ATATC committed Oct 4, 2024
1 parent e3daf5a commit 3c57a67
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions leads/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 3c57a67

Please sign in to comment.