import math import pytest from pygui.backend.frame_stats import compute_stats, Stats def test_basic_stat(): s = compute_stats([148.0, 150.0, 149.0]) assert s.min == 148.0 and s.min_index == 0 assert s.max == 150.0 and s.max_index == 1 assert s.diff == pytest.approx(2.0) assert s.avg == pytest.approx(149.0) assert s.sigma == pytest.approx(math.sqrt(2 / 3)) assert s.three_sigma == pytest.approx(3 * math.sqrt(2 / 3)) def test_empty_values_returns_zeros(): s = compute_stats([]) assert s == Stats(0.0, -1, 0.0, -1, 0.0, 0.0, 0.0, 0.0) def test_ignores_nan(): s = compute_stats([149.0, float("nan"), 151.0])