Skip to content

Commit 4d96865

Browse files
Amend documentation to use timestamp
The documentation in OrderedRingBuffer and MovingWindow is updated to reflect that the variables represented as datetime objects are actually timestamps. Signed-off-by: Daniel Zullo <[email protected]>
1 parent 8ae0c28 commit 4d96865

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

src/frequenz/sdk/timeseries/_moving_window.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def __init__( # pylint: disable=too-many-arguments
150150
given sampling period.
151151
input_sampling_period: The time interval between consecutive input samples.
152152
resampler_config: The resampler configuration in case resampling is required.
153-
align_to: A datetime object that defines a point in time to which
153+
align_to: A timestamp that defines a point in time to which
154154
the window is aligned to modulo window size. For further
155155
information, consult the class level documentation.
156156
name: The name of this moving window. If `None`, `str(id(self))` will be
@@ -299,10 +299,10 @@ def window(
299299
and returns an array.
300300
301301
Args:
302-
start: The start of the time interval. If `None`, the start of the
303-
window is used.
304-
end: The end of the time interval. If `None`, the end of the window
305-
is used.
302+
start: The start timestamp of the time interval. If `None`, the
303+
start of the window is used.
304+
end: The end timestamp of the time interval. If `None`, the end of
305+
the window is used.
306306
force_copy: If `True`, the returned array is a copy of the underlying
307307
data. Otherwise, if possible, a view of the underlying data is
308308
returned.
@@ -402,7 +402,7 @@ def __getitem__(self, key: SupportsIndex | datetime | slice) -> float | ArrayLik
402402
403403
* If the key is an integer, the float value of that key
404404
at the given position is returned.
405-
* If the key is a datetime object, the float value of that key
405+
* If the key is a timestamp, the float value of that key
406406
that corresponds to the timestamp is returned.
407407
* If the key is a slice of timestamps or integers, an ndarray is returned,
408408
where the bounds correspond to the slice bounds.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class Gap:
2424
"""A gap defines the range for which we haven't received values yet."""
2525

2626
start: datetime
27-
"""Start of the range, inclusive."""
27+
"""Start timestamp of the range, inclusive."""
2828
end: datetime
29-
"""End of the range, exclusive."""
29+
"""End timestamp of the range, exclusive."""
3030

3131
def contains(self, timestamp: datetime) -> bool:
3232
"""Check if a given timestamp is inside this gap.
@@ -271,7 +271,7 @@ def get_timestamp(self, index: int) -> datetime | None:
271271
index: Index to convert.
272272
273273
Returns:
274-
Datetime index where the value for the given index can be found.
274+
Timestamp where the value for the given index can be found.
275275
Or None if the buffer is empty.
276276
"""
277277
if self.oldest_timestamp is None:
@@ -323,8 +323,8 @@ def window(
323323
missing entries, they can safely do so.
324324
325325
Args:
326-
start: start time of the window.
327-
end: end time of the window.
326+
start: start timestamp of the window.
327+
end: end timestamp of the window.
328328
force_copy: optional, default True. If True, will always create a
329329
copy of the data.
330330
fill_value: If not None, will use this value to fill missing values.

tests/timeseries/test_moving_window.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ def init_moving_window(
6767

6868

6969
def dt(i: int) -> datetime: # pylint: disable=invalid-name
70-
"""Create datetime objects from indices.
70+
"""Create a timestamp from the given index.
7171
7272
Args:
73-
i: Index to create datetime from.
73+
i: The index to create a timestamp from.
7474
7575
Returns:
76-
Datetime object.
76+
The timestamp created from the index.
7777
"""
7878
return datetime.fromtimestamp(i, tz=timezone.utc)
7979

tests/timeseries/test_ringbuffer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,13 @@ def test_timestamp_ringbuffer_missing_parameter(
192192

193193

194194
def dt(i: int) -> datetime: # pylint: disable=invalid-name
195-
"""Create datetime objects from indices.
195+
"""Create a timestamp from the given index.
196196
197197
Args:
198-
i: Index to create datetime from.
198+
i: The index to create a timestamp from.
199199
200200
Returns:
201-
Datetime object.
201+
The timestamp created from the index.
202202
"""
203203
return datetime.fromtimestamp(i, tz=timezone.utc)
204204

0 commit comments

Comments
 (0)