Skip to content

Commit

Permalink
compare_logs: catch typeError (#23632)
Browse files Browse the repository at this point in the history
  • Loading branch information
pd0wm authored Jan 26, 2022
1 parent 9de8f8c commit 5ac3270
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions selfdrive/test/process_replay/compare_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,14 @@ def compare_logs(log1, log2, ignore_fields=None, ignore_msgs=None, tolerance=Non
# Dictdiffer only supports relative tolerance, we also want to check for absolute
# TODO: add this to dictdiffer
def outside_tolerance(diff):
if diff[0] == "change":
a, b = diff[2]
finite = math.isfinite(a) and math.isfinite(b)
if finite and isinstance(a, numbers.Number) and isinstance(b, numbers.Number):
return abs(a - b) > max(tolerance, tolerance * max(abs(a), abs(b)))
try:
if diff[0] == "change":
a, b = diff[2]
finite = math.isfinite(a) and math.isfinite(b)
if finite and isinstance(a, numbers.Number) and isinstance(b, numbers.Number):
return abs(a - b) > max(tolerance, tolerance * max(abs(a), abs(b)))
except TypeError:
pass
return True

dd = list(filter(outside_tolerance, dd))
Expand Down

0 comments on commit 5ac3270

Please sign in to comment.