From 73dc8e2f82fa2c072c0fcda71d97ffbd215d5a61 Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Mon, 16 Nov 2026 14:33:22 +0100 Subject: [PATCH] test(algo): keep the unmeasured #14191 guards pinned across libms The two guard tests failed on the ubuntu-24.04 gate job (run 43833457124) while they pass bit for bit on Windows: colour adaptation High gives (300,180) 64 instead of 65, rotation Low gives (285,220) 118 instead of 119, every other channel matches. Not a change from main: no commit between f143ce5849, where the samples were captured, and the branch parent eea585958 touches content_aware or inpaint, and the pins also hold here at RAYON_NUM_THREADS 4, 2 and 1. The vote that blends the seams between the copied pieces weights the patches with (-cost / (2 sigma2)).exp() of the host C library (inpaint/solver.rs); two samples sit right on a level boundary and round one level apart between glibc and the Windows runtime. Compare the nine samples of each option set within 2 levels per channel instead of bit for bit, list every sample over that slack in the failure message, and say in the code why. All 27 pinned values stay and the guard intent stays: unmeasured option sets keep today's fill. The pin still bites, because the structure path this PR adds moves these samples by tens of levels, 60 at (300,165) alone. --- .../content_aware/structure_continue_tests.rs | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/crates/algo/src/content_aware/structure_continue_tests.rs b/crates/algo/src/content_aware/structure_continue_tests.rs index 7c9b50becc..42ce605c12 100644 --- a/crates/algo/src/content_aware/structure_continue_tests.rs +++ b/crates/algo/src/content_aware/structure_continue_tests.rs @@ -214,10 +214,25 @@ fn rectangular_fill_keeps_the_band_and_stripe_phase_across_the_whole_hole() { assert_eq!((within, n), (10_000, 10_000), "{within} of {n} hole pixels carry the document's own colour within 12 levels (worst {worst})"); } +/// Per-channel slack for the unmeasured pins below. The exact values hold bit for bit on Windows +/// (also at RAYON_NUM_THREADS 4, 2 and 1), but not on every C library: the vote that blends the +/// seams between the copied pieces weights the patches with `(-cost / (2 sigma2)).exp()` of the +/// host C library (`inpaint/solver.rs`), and a filled pixel sitting right on a level boundary +/// rounds one level apart between glibc and the Windows runtime. CI run 43833457124 on +/// ubuntu-24.04 showed (300,180) under colour adaptation High at 64 instead of 65, and (285,220) +/// under rotation Low at 118 instead of 119, while all other 52 channels matched exactly. Nothing +/// on main changed these fills: between f143ce5849 and the branch parent eea585958 no commit +/// touches `content_aware` or `inpaint`. 2 levels is still a hard pin against what the guards +/// guard against: if the new patch radius leaked into one of these option sets, its fill would +/// move the way the measured set moves, and at (300,165) alone that is 60 levels (the None pin +/// 60,120,200 against the 120,170,230 the measured fill gives there). +const UNMEASURED_TOLERANCE: i32 = 2; + /// The option sets #14191 marks *not measured* on this document keep today's fill: these are the /// nine samples as main f143ce5849 (and as this branch without the change) gives them. Guard /// tests: they pass before and after the change and pin it, so widening the new patch radius later -/// has to say what these settings now do. +/// has to say what these settings now do. Compared within [`UNMEASURED_TOLERANCE`] levels per +/// channel, see there for why. fn unmeasured_colour_adaptation() -> Vec<(&'static str, FillOptions, [i32; 27])> { let at = |level: &str| FillOptions { color_adaptation: color_level(level), rotations: Vec::new(), scale: false, mirror: false, seed: 1 }; vec![ @@ -260,7 +275,20 @@ fn unmeasured_geometric_adaptation() -> Vec<(&'static str, FillOptions, [i32; 27 fn check_unmeasured(what: &str, opts: &FillOptions, want: &[i32; 27]) { let out = fill_measured_document("auto", opts); let got: Vec = SAMPLES.iter().flat_map(|((x, y), _)| filled_at(&out, *x, *y)).collect(); - assert_eq!(got.as_slice(), &want[..], "{what}: the nine samples changed, although #14191 marks that case not measured"); + let off: Vec = SAMPLES + .iter() + .enumerate() + .filter_map(|(k, ((x, y), _))| { + let (g, w) = (&got[k * 3..k * 3 + 3], &want[k * 3..k * 3 + 3]); + let dev = (0..3).map(|c| (g[c] - w[c]).abs()).max().unwrap_or(0); + (dev > UNMEASURED_TOLERANCE).then(|| format!("({x},{y}) -> {g:?}, today's fill {w:?}, off by {dev}")) + }) + .collect(); + assert!( + off.is_empty(), + "{what}: the nine samples moved by more than {UNMEASURED_TOLERANCE} levels, although #14191 marks that case not measured\n{}", + off.join("\n") + ); } #[test]