From b441c24eaaf1a26bfb6632f28315e79a2eea2183 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Sat, 14 Jan 2023 12:03:41 +1100 Subject: [PATCH] autotest: use percentage error when determining if z is preserved floating point storage means an absolute error doesn't work --- Tools/autotest/common.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Tools/autotest/common.py b/Tools/autotest/common.py index 674513bb65..28b645ed00 100644 --- a/Tools/autotest/common.py +++ b/Tools/autotest/common.py @@ -4241,9 +4241,13 @@ class AutoTest(ABC): raise NotAchievedException("Frame not same (got=%s want=%s)" % (self.string_for_frame(downloaded_item_val), self.string_for_frame(item_val))) - if abs(item.z - downloaded_item.z) > 1.0E-3: # error should be less than 1 mm - raise NotAchievedException("Z not preserved (got=%f want=%f)" % - (downloaded_item.z, item.z)) + if downloaded_item.z == 0: + delta = abs(item.z) + else: + delta = 1 - abs(item.z / downloaded_item.z) + if delta > 0.01: # error should be less than 1 mm, but float precision issues in Python... + raise NotAchievedException("Z not preserved (got=%f want=%f delta=%f%%)" % + (downloaded_item.z, item.z, delta)) def check_fence_items_same(self, want, got, strict=True): check_atts = ['mission_type', 'command', 'x', 'y', 'seq', 'param1']