Skip to content

Commit 90f5261

Browse files
igerberclaude
andcommitted
Address PR #391 R2 review (1 P3): tighten snapshot test to assert_array_equal
Reviewer noted the snapshot test docstring claims "byte-for-byte / bit identity" but the assertion was assert_allclose(atol=1e-14, rtol=1e-14), which is slightly weaker than the wording suggests. Switch to np.testing.assert_array_equal so the assertion strength matches the stated contract. Snapshot values are either exact f64 (Rademacher = +/-1.0) or computed once via correctly-rounded IEEE 754 sqrt in Rust (Mammen's golden-ratio constants, Webb's sqrt(N/2) constants), so cross-platform bit-equality holds on conformant hardware. Inline comment added explaining the safety argument. If a runner ever fails this test on a hardware/sqrt drift basis (very unlikely on x86_64 / aarch64 / ARM64 Windows), we'd learn something useful about that runner before deciding to soften the check. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 06b3b17 commit 90f5261

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

tests/test_rust_backend.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,13 @@ def test_bootstrap_weights_bit_identity_snapshot(self):
141141
}
142142
for weight_type, expected_arr in expected.items():
143143
actual = generate_bootstrap_weights_batch(2, 4, weight_type, 42)
144-
np.testing.assert_allclose(
144+
# Strict bit-identity: the snapshot values are either exact
145+
# (Rademacher = +/-1.0) or computed once via correctly-rounded
146+
# IEEE 754 sqrt in Rust (Mammen, Webb), so cross-platform
147+
# bit-equality holds on conformant hardware.
148+
np.testing.assert_array_equal(
145149
actual,
146150
expected_arr,
147-
atol=1e-14,
148-
rtol=1e-14,
149151
err_msg=f"{weight_type} bootstrap weights drifted from pinned baseline",
150152
)
151153

0 commit comments

Comments
 (0)