Here are two variables: earnings_forecast
, actual_earning
(numerical variables)
I want to assert if both these variables are equal with a diffe
For those who still use Python 2.x, you could also use numpy.isclose()
from numpy import isclose as isclose
a = 100.0
b = 100.01
print isclose(a,b, atol=0.02) # True
From the documentation:
For finite values, isclose uses the following equation to test whether two floating point values are equivalent.
absolute(a - b) <= (atol + rtol * absolute(b))