use tolerance when comparing values

This commit is contained in:
2025-07-23 09:20:52 +02:00
parent 1de6bfe63f
commit 1916a59d41

View File

@@ -1,4 +1,5 @@
import time
import math
def reread_limits_from_hw(motor):
@@ -15,7 +16,11 @@ def reread_limits_from_hw(motor):
time.sleep(2)
# Values should have been reread
assert motor.read_field('highlimit') == high_limit
assert motor.read_field('lowlimit') == low_limit
assert motor.read_field('dialhighlimit') == high_limit
assert motor.read_field('diallowlimit') == low_limit
assert math.isclose(motor.read_field('highlimit'),
high_limit, rel_tol=1e-9, abs_tol=0.001)
assert math.isclose(motor.read_field('lowlimit'),
low_limit, rel_tol=1e-9, abs_tol=0.001)
assert math.isclose(motor.read_field('dialhighlimit'),
high_limit, rel_tol=1e-9, abs_tol=0.001)
assert math.isclose(motor.read_field('diallowlimit'),
low_limit, rel_tol=1e-9, abs_tol=0.001)