Coverage for NeuralTSNE/NeuralTSNE/Utils/utils.py: 100%
2 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-18 16:32 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-18 16:32 +0000
1def does_sum_up_to(a: float, b: float, to: float, epsilon=1e-7) -> bool:
2 """
3 Check if the sum of two numbers, `a` and `b`, is approximately equal to a target value `to` within a given `epsilon`.
5 Parameters
6 ----------
7 `a` : `float`
8 The first number.
9 `b` : `float`
10 The second number.
11 `to` : `float`
12 The target sum value.
13 `epsilon` : `float`, optional
14 The acceptable margin of error. Defaults to `1e-7`.
16 Returns
17 -------
18 `bool`
19 `True` if the sum of `a` and `b` is within `epsilon` of the target value `to`, `False` otherwise.
20 """
21 return abs(a + b - to) < epsilon