chore: apply linting fixes and expand ruff coverage to test suite

This commit is contained in:
jack
2026-07-06 15:52:53 -07:00
parent d63332d619
commit 015642eea0
24 changed files with 144 additions and 67 deletions
+4 -6
View File
@@ -1,7 +1,6 @@
from pygui.backend.models.frame import Frame
from pygui.backend.models.threshold_classifier import ThresholdConfig, BAND_HIGH, BAND_IN, BAND_LOW
from pygui.backend.models.session_model import SessionModel, SessionUpdate
from pygui.backend.models.session_model import SessionModel
from pygui.backend.models.threshold_classifier import BAND_HIGH, BAND_IN, BAND_LOW, ThresholdConfig
def test_manual_banding_and_stats():
@@ -12,17 +11,16 @@ def test_manual_banding_and_stats():
assert update.stats.avg == 149.0
assert (update.target, update.margin) == (149.0, 1.0)
assert update.state in ("idle", "ramp", "set")
def test_auto_banding_uses_mean_and_sigma():
model = SessionModel(ThresholdConfig(auto=True))
# Tight cluster around 149 -> small σ -> the 200.0 outlier reads HIGH
update = model.process(Frame(seq=0, time=0.0, values=[149.0, 149.0, 149.0, 200.0]))
assert update.bands[3] == BAND_HIGH
assert update.target == update.stats.avg
def test_set_thresholds_reband_on_next_frame():
m = SessionModel(ThresholdConfig(set_point=149.0, margin=1.0, auto=False))
m.set_thresholds(ThresholdConfig(set_point=149.0, margin=5.0, auto=False))
upd = m.process(Frame(seq=0, time=0.0, values=[151.0]))
assert upd.bands == [BAND_IN]