Skip to content

Commit 9d54292

Browse files
Fix grid current formula generation
Add the formula operator if and only if there is a component to add. Otherwise, this was adding a `+` operator, but not adding a component after the `+`. Signed-off-by: Daniel Zullo <[email protected]>
1 parent 6d09aaa commit 9d54292

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/frequenz/sdk/timeseries/formula_engine/_formula_generators/_grid_current_formula.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ def _gen_phase_formula(
5252
# generate a formula that just adds values from all components that are
5353
# directly connected to the grid.
5454
for idx, comp in enumerate(grid_successors):
55-
if idx > 0:
56-
builder.push_oper("+")
57-
5855
# When inverters or ev chargers produce `None` samples, those
5956
# inverters are excluded from the calculation by treating their
6057
# `None` values as `0`s.
@@ -71,6 +68,9 @@ def _gen_phase_formula(
7168
else:
7269
continue
7370

71+
if idx > 0:
72+
builder.push_oper("+")
73+
7474
builder.push_component_metric(
7575
comp.component_id, nones_are_zeros=nones_are_zeros
7676
)

0 commit comments

Comments
 (0)