I have a class Vector that represents a point in 3-dimensional space. This vector has a method normalize(self, length = 1)
which scales the vector down/up
Use assertAlmostEqual
, assertNotAlmostEqual
.
From the official documentation:
assertAlmostEqual(first, second, places=7, msg=None, delta=None)
Test that first and second are approximately equal by computing the difference, rounding to the given number of decimal places (default 7), and comparing to zero.
Esentially No.
The floating point issue can't be bypassed, so you have either to "round" the result given by vec.normalize
or accept an almost-equal result (each one of the two is an approximation).