Skip to content

Commit fc45b9a

Browse files
committed
Deal with approximation on float
1 parent d33dbc0 commit fc45b9a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests_and_examples/run_query_tests.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,15 @@ def are_equal(expected, result):
368368
return False
369369
del result[index]
370370
return True
371-
371+
elif isinstance(expected, float):
372+
return SlicingDiceTester.float_is_close(expected, result)
372373
else:
373374
return expected == result
374375

376+
@staticmethod
377+
def float_is_close(a, b, rel_tol=1e-09, abs_tol=0.0):
378+
return abs(a - b) <= max(rel_tol * max(abs(a), abs(b)), abs_tol)
379+
375380
@staticmethod
376381
def indexof(x, result):
377382
for i in range(len(result)):

0 commit comments

Comments
 (0)