Separate forbidden ground from body collision and retain capture phase
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
"""Render jitter must not silently lower the requested capture rate."""
|
||||
import importlib
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def cadence(monkeypatch):
|
||||
monkeypatch.syspath_prepend(str(Path(__file__).parents[1] / "simulation/ai-polygon"))
|
||||
return importlib.import_module("scheduling_policy").CaptureCadence
|
||||
|
||||
|
||||
def test_ten_hz_capture_survives_sixteen_hz_render_quantization(cadence):
|
||||
clock = cadence(10, 0.)
|
||||
admitted = [i/16 for i in range(1, 161) if clock.due(i/16)]
|
||||
assert len(admitted) == 100
|
||||
assert all(0 <= actual - (i+1)/10 < 1/16 + 1e-9
|
||||
for i, actual in enumerate(admitted))
|
||||
assert set(round(b-a, 8) for a, b in zip(admitted, admitted[1:], strict=False)) == {.0625, .125}
|
||||
|
||||
|
||||
def test_overload_and_pause_discard_missed_slots_without_a_burst(cadence):
|
||||
clock = cadence(10, 100.)
|
||||
assert not clock.due(100.05)
|
||||
assert clock.due(102.035)
|
||||
assert not clock.due(102.035)
|
||||
assert not clock.due(102.05)
|
||||
assert clock.due(102.1)
|
||||
assert not clock.due(102.1)
|
||||
# A long operator pause creates no queued frames or catch-up workload.
|
||||
assert clock.due(500.07)
|
||||
assert not clock.due(500.08)
|
||||
assert clock.due(500.11)
|
||||
|
||||
|
||||
def test_invalid_clocks_and_rates_are_rejected(cadence):
|
||||
for rate in (0, -1, float("nan"), float("inf"), True):
|
||||
with pytest.raises(ValueError):
|
||||
cadence(rate, 0.)
|
||||
with pytest.raises(ValueError):
|
||||
cadence(10, float("nan"))
|
||||
with pytest.raises(ValueError):
|
||||
cadence(10, 0.).due(float("nan"))
|
||||
Reference in New Issue
Block a user