From a26d15378abeffa0c387f4410da74ece1f0dae56 Mon Sep 17 00:00:00 2001 From: AmitMY Date: Sat, 20 Jun 2026 18:38:18 +0200 Subject: [PATCH] Fix flaky normalize_distribution test: float32-tolerant comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test compares normalize_distribution output (float32, from the TF pose body) against a numpy reference (float64) using np.allclose with its default atol=1e-8. On near-zero normalized values, float32 rounding (~1e-7..1e-5) exceeds that tolerance, so the test flaked ~2% of runs depending on the random data. Reproduced at ~6/300 runs; root cause is purely the dtype mismatch (max abs diff ~1e-5, never a logic error). Use atol=1e-4 — well above float32 noise, still orders of magnitude tighter than any real regression in z-score output. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/python/tests/pose_tensorflow_test.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/python/tests/pose_tensorflow_test.py b/src/python/tests/pose_tensorflow_test.py index eefcf07..abfec76 100644 --- a/src/python/tests/pose_tensorflow_test.py +++ b/src/python/tests/pose_tensorflow_test.py @@ -133,7 +133,9 @@ def test_pose_tf_posebody_normalize_distribution_eager_mode_correct_result(self) actual_tensor_zero_filled = actual_tensor_nan_fixed.zero_filled() actual_tensor_as_numpy = actual_tensor_zero_filled.numpy() - self.assertTrue(np.allclose(actual_tensor_as_numpy, expected_tensor), + # actual is float32 (TF), expected is float64 (numpy); atol must tolerate + # float32 rounding on near-zero values, where allclose's default 1e-8 is too tight. + self.assertTrue(np.allclose(actual_tensor_as_numpy, expected_tensor, atol=1e-4), "Normalize distribution did not return the expected result.") def test_pose_tf_posebody_frame_dropout_normal_eager_mode_num_frames_not_zero(self):