Fix flaky optical flow test (compare numbers, not rendered image)#227
Merged
Conversation
The test rendered the optical flow as a matplotlib heatmap and compared the PNG against a checked-in reference with a 0.001 RMS tolerance. That comparison depends on matplotlib/freetype rendering, which drifts across CI runners and matplotlib versions (unpinned deps pull the newest on 3.11/3.12), so the test flaked on master while the underlying computation never changed. OpticalFlowCalculator is pure, deterministic numpy. Compare its output to a numeric .npy reference via np.allclose instead, removing matplotlib from the test entirely. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
After merging #226, master CI failed on
tests/optical_flow_test.py::test_optical_flow(Python 3.11/3.12) — unrelated to #226's changes. It also flaked on PRs.The test rendered the optical flow as a matplotlib heatmap, saved it to PNG, and compared against a checked-in reference image with a
0.001RMS tolerance. That comparison depends on matplotlib/freetype rendering, which drifts across CI runner images and matplotlib versions. With unpinned deps, 3.11/3.12 pull the newest matplotlib and render a hair differently → flake. The underlying computation never changed (byte-identical output locally, RMS match at tol=0).Fix
OpticalFlowCalculatoris pure, deterministic numpy. Compare its numeric output against a.npyreference vianp.allclose, dropping matplotlib from the test entirely. Same thing under test, no rendering dependency.tests/data/optical_flow.pngwithtests/data/optical_flow.npyNote
There's a separate genuinely seed-flaky test,
pose_tensorflow_test.py::test_pose_tf_posebody_normalize_distribution_eager_mode_correct_result(the one that flaked on #226's PR run): when a masked column has ≤1 unmasked value, std=0 makes the NumPy reference produce an unfillednanwhile the pose path runsfix_nan→0, soallclosefails. Not addressed here to keep this PR focused — happy to fix in a follow-up.🤖 Generated with Claude Code