Skip to content

Commit f22149d

Browse files
Remove absolute tolerance in floating-point comparison
The comparison of the max excess `take_from[1]` and `deficit` against zero was initially done using absolute tolerance. However, as both values are then compared against each other and known to be away from zero, the absolute tolerance becomes unnecessary. The relative tolerance, which is defined by default as 1e-09, is sufficient for this comparison. Signed-off-by: Daniel Zullo <[email protected]>
1 parent 1d45fc9 commit f22149d

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/frequenz/sdk/power/_distribution_algorithm.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,7 @@ def _distribute_power( # pylint: disable=too-many-arguments
404404
take_from = max(excess_reserved.items(), key=lambda item: item[1])
405405
if is_close_to_zero(take_from[1]) or take_from[1] < 0.0:
406406
break
407-
if take_from[1] >= -deficit or math.isclose(
408-
take_from[1], -deficit, abs_tol=1e-6
409-
):
407+
if take_from[1] >= -deficit or math.isclose(take_from[1], -deficit):
410408
excess_reserved[take_from[0]] += deficit
411409
deficits[inverter_id] = 0.0
412410
deficit = 0.0

0 commit comments

Comments
 (0)