mirror of
https://gitlvb.teallvbs.xyz/IQ.Lvbs/IQ.Pilot.git
synced 2026-07-24 21:12:05 +08:00
21 lines
520 B
Python
21 lines
520 B
Python
from collections import deque
|
|
|
|
from openpilot.system.ui.lib.scroll_panel2 import weighted_velocity
|
|
|
|
|
|
def test_weighted_velocity_empty():
|
|
assert weighted_velocity(deque()) == 0.0
|
|
|
|
|
|
def test_weighted_velocity_single():
|
|
assert weighted_velocity(deque([120.0])) == 120.0
|
|
|
|
|
|
def test_weighted_velocity_two_samples():
|
|
assert weighted_velocity(deque([100.0, 200.0])) == 130.0
|
|
|
|
|
|
def test_weighted_velocity_three_samples_biases_older():
|
|
velocity = weighted_velocity(deque([300.0, 180.0, 20.0]))
|
|
assert velocity == 244.0
|