Skip to content

Commit f034cc4

Browse files
authored
Use is_close_to_zero() instead of math.isclose(..., abs_tol=...)
We already have an utility function to check if a `float` is close to zero, so we can use that instead. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent c3418aa commit f034cc4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/frequenz/sdk/power/_distribution_algorithm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ def _distribute_power( # pylint: disable=too-many-arguments
400400
distribution[inverter.component_id] = excl_bound
401401

402402
for inverter_id, deficit in deficits.items():
403-
while not math.isclose(deficit, 0.0, abs_tol=1e-6) and deficit < 0.0:
403+
while not is_close_to_zero(deficit) and deficit < 0.0:
404404
take_from = max(excess_reserved.items(), key=lambda item: item[1])
405-
if math.isclose(take_from[1], 0.0, abs_tol=1e-6) or take_from[1] < 0.0:
405+
if is_close_to_zero(take_from[1]) or take_from[1] < 0.0:
406406
break
407407
if take_from[1] >= -deficit or math.isclose(
408408
take_from[1], -deficit, abs_tol=1e-6

0 commit comments

Comments
 (0)