It\'s well known that comparing floats for equality is a little fiddly due to rounding and precision issues.
For example: https://randomascii.wordpress.com/2012/02/2
Is something as simple as the following not good enough?
return abs(f1 - f2) <= allowed_error