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
+12 -8
View File
@@ -1,8 +1,13 @@
import math
from pygui.backend.models.threshold_classifier import (
ThresholdConfig, classify, classify_all, resolve_bounds,
BAND_IN, BAND_HIGH, BAND_LOW
BAND_HIGH,
BAND_IN,
BAND_LOW,
ThresholdConfig,
classify,
classify_all,
resolve_bounds,
)
@@ -11,19 +16,18 @@ def test_classify_about_target_margin():
assert classify(149.9, target=149.0, margin=1.0) ==BAND_IN # within
assert classify(150.5, target=149.0, margin=1.0) ==BAND_HIGH # 1.5 above
assert classify(147.5, target=149.0, margin=1.0) ==BAND_LOW # 1.5 below
def test_manual_bounds_use_set_point_and_margin():
cfg = ThresholdConfig(set_point=149.0, margin=1.0, auto=False)
assert resolve_bounds([200.0, 0.0], cfg) == (149.0, 1.0)
def test_auto_bounds_use_mean_and_sigma():
cfg = ThresholdConfig(auto=True)
target, margin = resolve_bounds([148.0, 150.0, 149.0], cfg)
assert target == 149.0
assert margin == math.sqrt(2 / 3)
assert margin == math.sqrt(2 / 3)
def test_classify_all_manual():
cfg = ThresholdConfig(set_point=149.0, margin=1.0, auto=False)
assert classify_all([149.0, 151.0, 147.0], cfg) == [BAND_IN, BAND_HIGH, BAND_LOW]