13
13
# equivalence of floating point representations with finite precision
14
14
𝜀 = 1e-8
15
15
# True, iff two floats agree up to the (absolute) precision 𝜀
16
- def equiv (x : float , y : float ) -> bool :
16
+ def _equiv (x : float , y : float ) -> bool :
17
17
return abs (x - y ) < 𝜀
18
18
19
19
20
20
# True, iff two vectors component-wise agree up to the (absolute) precision 𝜀
21
- def vec_equiv (x : AbstractVector , y : AbstractVector ) -> bool :
22
- return equiv (x [0 ], y [0 ]) and equiv (x [1 ], y [1 ]) and equiv (x [2 ], y [2 ])
21
+ def _vec_equiv (x : AbstractVector , y : AbstractVector ) -> bool :
22
+ return _equiv (x [0 ], y [0 ]) and _equiv (x [1 ], y [1 ]) and _equiv (x [2 ], y [2 ])
23
23
24
24
25
25
# standart Carthesian basis
@@ -40,7 +40,7 @@ def assertEquiv(self, x: float, y: float) -> None:
40
40
Note: This replaces assertTrue(x == y) for float.
41
41
"""
42
42
try :
43
- self .assertTrue (equiv (x , y ))
43
+ self .assertTrue (_equiv (x , y ))
44
44
except AssertionError as ae :
45
45
raise AssertionError (
46
46
"Scalar {} is not equivalent to {}." .format (x , y )
@@ -52,7 +52,7 @@ def assertVectorEquiv(self, x: AbstractVector, y: AbstractVector) -> None:
52
52
Note: This replaces assertTrue(x == y) for nerte.Vector.
53
53
"""
54
54
try :
55
- self .assertTrue (vec_equiv (x , y ))
55
+ self .assertTrue (_vec_equiv (x , y ))
56
56
except AssertionError as ae :
57
57
raise AssertionError (
58
58
"Vector {} is not equivalent to {}." .format (x , y )
0 commit comments