From b1e1299b92cc40c6cbd5451318ae85b7a02e1d35 Mon Sep 17 00:00:00 2001 From: T3vl <80123588+tealtwo@users.noreply.github.com> Date: Mon, 2 Feb 2026 15:41:45 -0600 Subject: [PATCH 1/2] Add numpy_fast.py with clip, interp, and mean functions --- common/numpy_fast.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 common/numpy_fast.py diff --git a/common/numpy_fast.py b/common/numpy_fast.py new file mode 100644 index 0000000000..878c0005c8 --- /dev/null +++ b/common/numpy_fast.py @@ -0,0 +1,19 @@ +def clip(x, lo, hi): + return max(lo, min(hi, x)) + +def interp(x, xp, fp): + N = len(xp) + + def get_interp(xv): + hi = 0 + while hi < N and xv > xp[hi]: + hi += 1 + low = hi - 1 + return fp[-1] if hi == N and xv > xp[low] else ( + fp[0] if hi == 0 else + (xv - xp[low]) * (fp[hi] - fp[low]) / (xp[hi] - xp[low]) + fp[low]) + + return [get_interp(v) for v in x] if hasattr(x, '__iter__') else get_interp(x) + +def mean(x): + return sum(x) / len(x) From 8dbb5af907b8770c54a15aa9655ce95a8ff4f397 Mon Sep 17 00:00:00 2001 From: T3vl <80123588+tealtwo@users.noreply.github.com> Date: Mon, 2 Feb 2026 15:44:42 -0600 Subject: [PATCH 2/2] BMW: bugfix import in CC --- opendbc_repo/opendbc/car/bmw/carcontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opendbc_repo/opendbc/car/bmw/carcontroller.py b/opendbc_repo/opendbc/car/bmw/carcontroller.py index 95f4cab22f..a8ab0992b4 100644 --- a/opendbc_repo/opendbc/car/bmw/carcontroller.py +++ b/opendbc_repo/opendbc/car/bmw/carcontroller.py @@ -6,7 +6,7 @@ from opendbc.car.interfaces import CarControllerBase from opendbc.can.packer import CANPacker from opendbc.car.common.conversions import Conversions as CV -from common import numpy_fast as np +import common.numpy_fast as np VisualAlert = car_capnp.CarControl.HUDControl.VisualAlert