Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/s2python/common/power_forecast_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def validate_values_at_most_one_per_commodity_quantity(self) -> Self:
if has_value.get(value.commodity_quantity, False):
raise ValueError(
self,
f"There must be at most 1 PowerForecastValue per CommodityQuantity",
"There must be at most 1 PowerForecastValue per CommodityQuantity",
)
has_value[value.commodity_quantity] = True

Expand Down
4 changes: 2 additions & 2 deletions src/s2python/common/power_measurement.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import uuid
from typing import List
from typing_extensions import Self
import uuid

from pydantic import model_validator
from s2python.common.power_value import PowerValue
Expand Down Expand Up @@ -32,7 +32,7 @@ def validate_values_at_most_one_per_commodity_quantity(self) -> Self:
if has_value.get(value.commodity_quantity, False):
raise ValueError(
self,
f"The measured PowerValues must contain at most one item per CommodityQuantity.",
"The measured PowerValues must contain at most one item per CommodityQuantity.",
)

has_value[value.commodity_quantity] = True
Expand Down
5 changes: 2 additions & 3 deletions src/s2python/pebc/pebc_allowed_limit_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,14 @@ class PEBCAllowedLimitRange(GenPEBCAllowedLimitRange, S2MessageComponent):

@model_validator(mode="after")
def validate_range_boundary(self) -> Self:
# According to the specification "There shall be at least one PEBC.AllowedLimitRange for the UPPER_LIMIT
# According to the specification "There must be at least one PEBC.AllowedLimitRange for the UPPER_LIMIT
# and at least one AllowedLimitRange for the LOWER_LIMIT." However for something that produces energy
# end_of_range=-2000 and start_of_range=0 is valid. Therefore absolute value used here.
# TODO: Check that this is the correct interpretation of the wording
if abs(self.range_boundary.start_of_range) > abs(
self.range_boundary.end_of_range
):
raise ValueError(
self,
f"The start of the range must shall be smaller or equal than the end of the range.",
"The start of the range must be smaller or equal than the end of the range.",
)
return self
8 changes: 4 additions & 4 deletions src/s2python/pebc/pebc_power_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from pydantic import model_validator

from s2python.common import CommodityQuantity, NumberRange
from s2python.common import CommodityQuantity
from s2python.generated.gen_s2 import (
PEBCPowerConstraints as GenPEBCPowerConstraints,
PEBCPowerEnvelopeConsequenceType as GenPEBCPowerEnvelopeConsequenceType,
Expand Down Expand Up @@ -60,10 +60,10 @@ def validate_has_one_upper_one_lower_limit_range(self) -> Self:
for upper, lower in commodity_type_ranges.values():
valid = valid and upper and lower

if not (valid):
if not valid:
raise ValueError(
self,
f"There shall be at least one PEBC.AllowedLimitRange for the UPPER_LIMIT and at least one AllowedLimitRange for the LOWER_LIMIT.",
"There shall be at least one PEBC.AllowedLimitRange for the UPPER_LIMIT and at least one AllowedLimitRange for the LOWER_LIMIT.",
)

return self
Expand All @@ -72,6 +72,6 @@ def validate_has_one_upper_one_lower_limit_range(self) -> Self:
def validate_valid_until_after_valid_from(self) -> Self:
if self.valid_until is not None and self.valid_until < self.valid_from:
raise ValueError(
self, f"valid_until cannot be set to a value that is before valid_from."
self, "valid_until cannot be set to a value that is before valid_from."
)
return self
4 changes: 1 addition & 3 deletions tests/unit/common/power_forecast_element_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import datetime
import json
from datetime import timedelta
from unittest import TestCase
import uuid

from s2python.s2_validation_error import S2ValidationError

Expand Down Expand Up @@ -81,4 +79,4 @@ def test__init__multiple_power_forecast_values_for_commodity_quantity(self):
)
],
duration=Duration.from_timedelta(timedelta(seconds=4)),
)
)