Skip to content

Commit 1957d1b

Browse files
committed
Change the default alignment to UNIX_EPOCH
This is to be consistent with the resampler. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent d0dcc8d commit 1957d1b

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252

5353
Note that the parameter `sampling_period` has been renamed to `input_sampling_period` to better distinguish it from the sampling period parameter in the `resampler_config`.
5454

55+
* Use the `UNIX_EPOCH` as the default alignment.
56+
5557
* `Resampler`
5658

5759
* The `ResamplerConfig` now takes the resampling period as a `timedelta`. The configuration was renamed from `resampling_period_s` to `resampling_period` accordingly.

src/frequenz/sdk/timeseries/_moving_window.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import logging
1010
import math
1111
from collections.abc import Sequence
12-
from datetime import datetime, timedelta, timezone
12+
from datetime import datetime, timedelta
1313
from typing import SupportsIndex, overload
1414

1515
import numpy as np
@@ -18,6 +18,7 @@
1818

1919
from .._internal.asyncio import cancel_and_await
2020
from . import Sample
21+
from ._base_types import UNIX_EPOCH
2122
from ._resampling import Resampler, ResamplerConfig
2223
from ._ringbuffer import OrderedRingBuffer
2324

@@ -106,7 +107,7 @@ def __init__( # pylint: disable=too-many-arguments
106107
resampled_data_recv: Receiver[Sample],
107108
input_sampling_period: timedelta,
108109
resampler_config: ResamplerConfig | None = None,
109-
window_alignment: datetime = datetime(1, 1, 1, tzinfo=timezone.utc),
110+
window_alignment: datetime = UNIX_EPOCH,
110111
) -> None:
111112
"""
112113
Initialize the MovingWindow.
@@ -122,9 +123,8 @@ def __init__( # pylint: disable=too-many-arguments
122123
input_sampling_period: The time interval between consecutive input samples.
123124
resampler_config: The resampler configuration in case resampling is required.
124125
window_alignment: A datetime object that defines a point in time to which
125-
the window is aligned to modulo window size.
126-
(default is 0001-01-01T00:00:00+00:00)
127-
For further information, consult the class level documentation.
126+
the window is aligned to modulo window size. For further
127+
information, consult the class level documentation.
128128
129129
Raises:
130130
asyncio.CancelledError: when the task gets cancelled.

src/frequenz/sdk/timeseries/_ringbuffer/buffer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import numpy.typing as npt
1616

1717
from .. import Sample
18+
from .._base_types import UNIX_EPOCH
1819

1920
FloatArray = TypeVar("FloatArray", List[float], npt.NDArray[np.float64])
2021

@@ -53,7 +54,7 @@ def __init__(
5354
self,
5455
buffer: FloatArray,
5556
sampling_period: timedelta,
56-
time_index_alignment: datetime = datetime(1, 1, 1, tzinfo=timezone.utc),
57+
time_index_alignment: datetime = UNIX_EPOCH,
5758
) -> None:
5859
"""Initialize the time aware ringbuffer.
5960

0 commit comments

Comments
 (0)