Skip to content

Commit ebb0e2d

Browse files
committed
Make internal SystemBounds class kw_only
Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 88caff3 commit ebb0e2d

File tree

2 files changed

+42
-40
lines changed

2 files changed

+42
-40
lines changed

src/frequenz/sdk/timeseries/_base_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class Bounds(Generic[_T]):
154154
"""Upper bound."""
155155

156156

157-
@dataclass(frozen=True)
157+
@dataclass(frozen=True, kw_only=True)
158158
class SystemBounds:
159159
"""Internal representation of system bounds for groups of components."""
160160

tests/timeseries/_battery_pool/test_battery_pool.py

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -890,9 +890,11 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
890890
"active_power_exclusion_lower_bound": -400,
891891
},
892892
SystemBounds(
893-
now,
894-
Bounds(Power.from_watts(-1000), Power.from_watts(10000)),
895-
Bounds(Power.from_watts(-700), Power.from_watts(600)),
893+
timestamp=now,
894+
inclusion_bounds=Bounds(
895+
Power.from_watts(-1000), Power.from_watts(10000)
896+
),
897+
exclusion_bounds=Bounds(Power.from_watts(-700), Power.from_watts(600)),
896898
),
897899
),
898900
# Inverter bound changed, but metric result should not change.
@@ -903,9 +905,9 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
903905
"active_power_exclusion_upper_bound": 250,
904906
},
905907
expected_result=SystemBounds(
906-
now,
907-
None,
908-
None,
908+
timestamp=now,
909+
inclusion_bounds=None,
910+
exclusion_bounds=None,
909911
),
910912
wait_for_result=False,
911913
),
@@ -918,9 +920,9 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
918920
"power_exclusion_upper_bound": 100,
919921
},
920922
SystemBounds(
921-
now,
922-
Bounds(Power.from_watts(-900), Power.from_watts(9000)),
923-
Bounds(Power.from_watts(-700), Power.from_watts(550)),
923+
timestamp=now,
924+
inclusion_bounds=Bounds(Power.from_watts(-900), Power.from_watts(9000)),
925+
exclusion_bounds=Bounds(Power.from_watts(-700), Power.from_watts(550)),
924926
),
925927
),
926928
Scenario(
@@ -932,9 +934,9 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
932934
"power_exclusion_upper_bound": 5,
933935
},
934936
SystemBounds(
935-
now,
936-
Bounds(Power.from_watts(-10), Power.from_watts(4200)),
937-
Bounds(Power.from_watts(-600), Power.from_watts(450)),
937+
timestamp=now,
938+
inclusion_bounds=Bounds(Power.from_watts(-10), Power.from_watts(4200)),
939+
exclusion_bounds=Bounds(Power.from_watts(-600), Power.from_watts(450)),
938940
),
939941
),
940942
Scenario(
@@ -946,9 +948,9 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
946948
"active_power_exclusion_upper_bound": math.nan,
947949
},
948950
SystemBounds(
949-
now,
950-
Bounds(Power.from_watts(-10), Power.from_watts(200)),
951-
Bounds(Power.from_watts(-200), Power.from_watts(200)),
951+
timestamp=now,
952+
inclusion_bounds=Bounds(Power.from_watts(-10), Power.from_watts(200)),
953+
exclusion_bounds=Bounds(Power.from_watts(-200), Power.from_watts(200)),
952954
),
953955
),
954956
Scenario(
@@ -960,9 +962,9 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
960962
"power_exclusion_upper_bound": 50,
961963
},
962964
SystemBounds(
963-
now,
964-
None,
965-
None,
965+
timestamp=now,
966+
inclusion_bounds=None,
967+
exclusion_bounds=None,
966968
),
967969
),
968970
Scenario(
@@ -974,9 +976,9 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
974976
"power_exclusion_upper_bound": 20,
975977
},
976978
SystemBounds(
977-
now,
978-
Bounds(Power.from_watts(-100), Power.from_watts(100)),
979-
Bounds(Power.from_watts(-70), Power.from_watts(70)),
979+
timestamp=now,
980+
inclusion_bounds=Bounds(Power.from_watts(-100), Power.from_watts(100)),
981+
exclusion_bounds=Bounds(Power.from_watts(-70), Power.from_watts(70)),
980982
),
981983
wait_for_result=False,
982984
),
@@ -989,9 +991,9 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
989991
"active_power_exclusion_upper_bound": 100,
990992
},
991993
SystemBounds(
992-
now,
993-
Bounds(Power.from_watts(-500), Power.from_watts(500)),
994-
Bounds(Power.from_watts(-120), Power.from_watts(120)),
994+
timestamp=now,
995+
inclusion_bounds=Bounds(Power.from_watts(-500), Power.from_watts(500)),
996+
exclusion_bounds=Bounds(Power.from_watts(-120), Power.from_watts(120)),
995997
),
996998
wait_for_result=False,
997999
),
@@ -1004,9 +1006,9 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
10041006
"power_exclusion_upper_bound": 130,
10051007
},
10061008
SystemBounds(
1007-
now,
1008-
Bounds(Power.from_watts(-300), Power.from_watts(400)),
1009-
Bounds(Power.from_watts(-130), Power.from_watts(130)),
1009+
timestamp=now,
1010+
inclusion_bounds=Bounds(Power.from_watts(-300), Power.from_watts(400)),
1011+
exclusion_bounds=Bounds(Power.from_watts(-130), Power.from_watts(130)),
10101012
),
10111013
),
10121014
Scenario(
@@ -1018,9 +1020,9 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
10181020
"active_power_exclusion_upper_bound": 80,
10191021
},
10201022
SystemBounds(
1021-
now,
1022-
Bounds(Power.from_watts(-400), Power.from_watts(450)),
1023-
Bounds(Power.from_watts(-210), Power.from_watts(210)),
1023+
timestamp=now,
1024+
inclusion_bounds=Bounds(Power.from_watts(-400), Power.from_watts(450)),
1025+
exclusion_bounds=Bounds(Power.from_watts(-210), Power.from_watts(210)),
10241026
),
10251027
),
10261028
]
@@ -1034,14 +1036,14 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
10341036
batteries_in_pool=batteries_in_pool,
10351037
waiting_time_sec=waiting_time_sec,
10361038
all_pool_result=SystemBounds(
1037-
now,
1038-
Bounds(Power.from_watts(-400), Power.from_watts(450)),
1039-
Bounds(Power.from_watts(-210), Power.from_watts(210)),
1039+
timestamp=now,
1040+
inclusion_bounds=Bounds(Power.from_watts(-400), Power.from_watts(450)),
1041+
exclusion_bounds=Bounds(Power.from_watts(-210), Power.from_watts(210)),
10401042
),
10411043
only_first_battery_result=SystemBounds(
1042-
now,
1043-
Bounds(Power.from_watts(-100), Power.from_watts(50)),
1044-
Bounds(Power.from_watts(-80), Power.from_watts(80)),
1044+
timestamp=now,
1045+
inclusion_bounds=Bounds(Power.from_watts(-100), Power.from_watts(50)),
1046+
exclusion_bounds=Bounds(Power.from_watts(-80), Power.from_watts(80)),
10451047
),
10461048
)
10471049

@@ -1052,9 +1054,9 @@ async def run_power_bounds_test( # pylint: disable=too-many-locals
10521054
compare_messages(
10531055
msg,
10541056
SystemBounds(
1055-
now,
1056-
Bounds(Power.from_watts(-300), Power.from_watts(400)),
1057-
Bounds(Power.from_watts(-130), Power.from_watts(130)),
1057+
timestamp=now,
1058+
inclusion_bounds=Bounds(Power.from_watts(-300), Power.from_watts(400)),
1059+
exclusion_bounds=Bounds(Power.from_watts(-130), Power.from_watts(130)),
10581060
),
10591061
0.2,
10601062
)

0 commit comments

Comments
 (0)