From 2ba329d599a1402bbee8818caaf56190665d59d5 Mon Sep 17 00:00:00 2001 From: Chadwick Boulay Date: Fri, 26 Jun 2026 02:02:26 -0400 Subject: [PATCH] De-flake test_decimate_system: compare overlapping prefix The raw and decimated streams are logged by independent MessageLoggers, and the graph terminates on the output count (TERM watches LOGFILT), so the raw log can end a message or two ahead of the filtered log. `expected` (built from all raw samples) was then longer than `outputs`, intermittently failing the full-length np.allclose with a shape mismatch (e.g. (100,8) vs (120,8)) under CI load. The anti-alias filter is causal and zi-initialized, so each stream is a prefix of a longer run; compare only the overlapping prefix. This mirrors the truncation test_filter_system already applies for the same termination race. --- tests/integration/ezmsg/test_decimate_system.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/integration/ezmsg/test_decimate_system.py b/tests/integration/ezmsg/test_decimate_system.py index 443fb66d..8af84cb5 100644 --- a/tests/integration/ezmsg/test_decimate_system.py +++ b/tests/integration/ezmsg/test_decimate_system.py @@ -54,4 +54,13 @@ def test_decimate_system(target_rate: float): antialiased, _ = scipy.signal.lfilter(b, a, inputs.data, axis=0, zi=zi) expected = antialiased[:: int(expected_factor)] - assert np.allclose(outputs.data, expected) + # The raw and decimated streams are logged by independent MessageLoggers, and + # the graph is torn down on the *output* count (TERM watches LOGFILT), so the + # raw log can end a message or two ahead of the filtered log -- leaving + # `expected` (built from all raw samples) longer than `outputs`. The anti-alias + # filter is causal and zi-initialized, so each stream is a prefix of a longer + # run; compare only the overlapping prefix rather than requiring equal length. + # (test_filter_system applies the same truncation for the same race.) + n = min(outputs.data.shape[0], expected.shape[0]) + assert n > 0 + np.testing.assert_allclose(outputs.data[:n], expected[:n])