Skip to content

Commit 62b1f59

Browse files
committed
Rename power distributing actor result OutOfBound -> OutOfBounds
Also rename `OutOfBounds.bound` to `OutOfBounds.bounds`. Because bounds are a range and not a single value in a single direction, calling it `Bounds` is more accurate. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 40d9355 commit 62b1f59

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

benchmarks/power_distribution/power_distributor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from frequenz.sdk.actor.power_distributing import (
1818
BatteryStatus,
1919
Error,
20-
OutOfBound,
20+
OutOfBounds,
2121
PartialFailure,
2222
PowerDistributingActor,
2323
Request,
@@ -75,7 +75,7 @@ def parse_result(result: List[List[Result]]) -> Dict[str, float]:
7575
Error: 0,
7676
Success: 0,
7777
PartialFailure: 0,
78-
OutOfBound: 0,
78+
OutOfBounds: 0,
7979
}
8080

8181
for result_list in result:
@@ -86,7 +86,7 @@ def parse_result(result: List[List[Result]]) -> Dict[str, float]:
8686
"success_num": result_counts[Success],
8787
"failed_num": result_counts[PartialFailure],
8888
"error_num": result_counts[Error],
89-
"out_of_bound": result_counts[OutOfBound],
89+
"out_of_bounds": result_counts[OutOfBounds],
9090
}
9191

9292

src/frequenz/sdk/actor/power_distributing/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
from ._battery_pool_status import BatteryStatus
1414
from .power_distributing import PowerDistributingActor
1515
from .request import Request
16-
from .result import Error, OutOfBound, PartialFailure, Result, Success
16+
from .result import Error, OutOfBounds, PartialFailure, Result, Success
1717

1818
__all__ = [
1919
"PowerDistributingActor",
2020
"Request",
2121
"Result",
2222
"Error",
2323
"Success",
24-
"OutOfBound",
24+
"OutOfBounds",
2525
"PartialFailure",
2626
"BatteryStatus",
2727
]

src/frequenz/sdk/actor/power_distributing/power_distributing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
InvBatPair,
4444
)
4545
from .request import Request
46-
from .result import Error, OutOfBound, PartialFailure, PowerBounds, Result, Success
46+
from .result import Error, OutOfBounds, PartialFailure, PowerBounds, Result, Success
4747

4848
_logger = logging.getLogger(__name__)
4949

@@ -482,7 +482,7 @@ def _check_request(
482482
# If the requested power is in the exclusion bounds, it is NOT possible to
483483
# increase it so that it is outside the exclusion bounds.
484484
if bounds.exclusion_lower < request.power < bounds.exclusion_upper:
485-
return OutOfBound(request=request, bound=bounds)
485+
return OutOfBounds(request=request, bounds=bounds)
486486
else:
487487
in_lower_range = (
488488
bounds.inclusion_lower <= request.power <= bounds.exclusion_lower
@@ -491,7 +491,7 @@ def _check_request(
491491
bounds.exclusion_upper <= request.power <= bounds.inclusion_upper
492492
)
493493
if not (in_lower_range or in_upper_range):
494-
return OutOfBound(request=request, bound=bounds)
494+
return OutOfBounds(request=request, bounds=bounds)
495495

496496
return None
497497

src/frequenz/sdk/actor/power_distributing/result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ class PowerBounds:
8888

8989

9090
@dataclasses.dataclass
91-
class OutOfBound(Result):
91+
class OutOfBounds(Result):
9292
"""Result returned when the power was not set because it was out of bounds.
9393
9494
This result happens when the originating request was done with
9595
`adjust_power = False` and the requested power is not within the batteries bounds.
9696
"""
9797

98-
bound: PowerBounds
98+
bounds: PowerBounds
9999
"""The power bounds for the requested batteries.
100100
101101
If the requested power negative, then this value is the lower bound.

tests/actor/power_distributing/test_power_distributing.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from frequenz.sdk.actor.power_distributing._battery_pool_status import BatteryPoolStatus
2626
from frequenz.sdk.actor.power_distributing.result import (
2727
Error,
28-
OutOfBound,
28+
OutOfBounds,
2929
PowerBounds,
3030
Result,
3131
Success,
@@ -448,10 +448,10 @@ async def test_power_distributor_one_user_adjust_power_consume(
448448
assert len(done) == 1
449449

450450
result = done.pop().result()
451-
assert isinstance(result, OutOfBound)
451+
assert isinstance(result, OutOfBounds)
452452
assert result is not None
453453
assert result.request == request
454-
assert result.bound.inclusion_upper == 1000
454+
assert result.bounds.inclusion_upper == 1000
455455

456456
async def test_power_distributor_one_user_adjust_power_supply(
457457
self, mocker: MockerFixture
@@ -501,10 +501,10 @@ async def test_power_distributor_one_user_adjust_power_supply(
501501
assert len(done) == 1
502502

503503
result = done.pop().result()
504-
assert isinstance(result, OutOfBound)
504+
assert isinstance(result, OutOfBounds)
505505
assert result is not None
506506
assert result.request == request
507-
assert result.bound.inclusion_lower == -1000
507+
assert result.bounds.inclusion_lower == -1000
508508

509509
async def test_power_distributor_one_user_adjust_power_success(
510510
self, mocker: MockerFixture

0 commit comments

Comments
 (0)