Skip to content

Commit 5ee9a78

Browse files
committed
Make the MovingWindow constructor keyword-only
The `MovingWindow` constructor now takes all arguments as keyword-only to avoid mistakes, such as confusing the `size` with the `input_sampling_period`. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent fa747fc commit 5ee9a78

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

RELEASE_NOTES.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
actor = ConfigManagingActor(config_files=["config.toml"])
1616
```
1717

18+
* The `MovingWindow` now take all arguments as keyword-only to avoid mistakes.
19+
1820
## New Features
1921

2022
- The `ConfigManagingActor` can now take multiple configuration files as input, allowing to override default configurations with custom configurations.

benchmarks/timeseries/periodic_feature_extractor.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ async def init_feature_extractor(
3535
# We only need the moving window to initialize the PeriodicFeatureExtractor class.
3636
lm_chan = Broadcast[Sample[Quantity]](name="lm_net_power")
3737
async with MovingWindow(
38-
timedelta(seconds=1), lm_chan.new_receiver(), timedelta(seconds=1)
38+
size=timedelta(seconds=1),
39+
resampled_data_recv=lm_chan.new_receiver(),
40+
input_sampling_period=timedelta(seconds=1),
3941
) as moving_window:
4042
await lm_chan.new_sender().send(
4143
Sample(datetime.now(tz=timezone.utc), Quantity(0))

src/frequenz/sdk/timeseries/_moving_window.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ async def run() -> None:
130130

131131
def __init__( # pylint: disable=too-many-arguments
132132
self,
133+
*,
133134
size: timedelta,
134135
resampled_data_recv: Receiver[Sample[Quantity]],
135136
input_sampling_period: timedelta,
136137
resampler_config: ResamplerConfig | None = None,
137138
align_to: datetime = UNIX_EPOCH,
138-
*,
139139
name: str | None = None,
140140
) -> None:
141141
"""

tests/timeseries/test_moving_window.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ def init_moving_window(
5959
"""
6060
lm_chan = Broadcast[Sample[Quantity]](name="lm_net_power")
6161
lm_tx = lm_chan.new_sender()
62-
window = MovingWindow(size, lm_chan.new_receiver(), timedelta(seconds=1))
62+
window = MovingWindow(
63+
size=size,
64+
resampled_data_recv=lm_chan.new_receiver(),
65+
input_sampling_period=timedelta(seconds=1),
66+
)
6367
return window, lm_tx
6468

6569

tests/timeseries/test_periodic_feature_extractor.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ async def init_feature_extractor_no_data(
6060
# We only need the moving window to initialize the PeriodicFeatureExtractor class.
6161
lm_chan = Broadcast[Sample[Quantity]](name="lm_net_power")
6262
moving_window = MovingWindow(
63-
timedelta(seconds=1), lm_chan.new_receiver(), timedelta(seconds=1)
63+
size=timedelta(seconds=1),
64+
resampled_data_recv=lm_chan.new_receiver(),
65+
input_sampling_period=timedelta(seconds=1),
6466
)
6567
async with moving_window:
6668
await lm_chan.new_sender().send(

0 commit comments

Comments
 (0)