Skip to content

Commit bc4fb55

Browse files
committed
Rename time bound properties in ring buffer
Signed-off-by: cwasicki <[email protected]>
1 parent 5dd2288 commit bc4fb55

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

src/frequenz/sdk/timeseries/_moving_window.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ def __getitem__(self, key: SupportsIndex | datetime | slice) -> float | ArrayLik
323323
key = slice(slice(key.start, key.stop).indices(self.__len__()))
324324
elif isinstance(key.start, datetime) or isinstance(key.stop, datetime):
325325
if key.start is None:
326-
key = slice(self._buffer.time_bound_oldest, key.stop)
326+
key = slice(self._buffer.oldest_timestamp, key.stop)
327327
if key.stop is None:
328-
key = slice(key.start, self._buffer.time_bound_newest)
328+
key = slice(key.start, self._buffer.newest_timestamp)
329329

330330
_logger.debug("Returning slice for [%s:%s].", key.start, key.stop)
331331

src/frequenz/sdk/timeseries/_periodic_feature_extractor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ def _timestamp_to_rel_index(self, timestamp: datetime) -> int:
172172

173173
# distance between the input ts and the ts of oldest known samples (in samples)
174174
dist_to_oldest = int(
175-
(timestamp - self._buffer.time_bound_oldest) / self._sampling_period
175+
(timestamp - self._buffer.oldest_timestamp) / self._sampling_period
176176
)
177177

178178
_logger.debug("Shifting ts: %s", timestamp)
179-
_logger.debug("Oldest timestamp in buffer: %s", self._buffer.time_bound_oldest)
179+
_logger.debug("Oldest timestamp in buffer: %s", self._buffer.oldest_timestamp)
180180
_logger.debug("Distance to the oldest sample: %i", dist_to_oldest)
181181

182182
return dist_to_oldest
@@ -274,7 +274,7 @@ def _get_relative_positions(
274274

275275
# check if the newest time bound, i.e. the sample that is currently written,
276276
# is inside the interval
277-
rb_current_position = self._buffer.time_bound_newest
277+
rb_current_position = self._buffer.newest_timestamp
278278
rel_next_position = (
279279
self._timestamp_to_rel_index(rb_current_position) + 1
280280
) % self._period
@@ -338,7 +338,7 @@ def _get_buffer_bounds(
338338

339339
# get the start and end position inside the ringbuffer
340340
end_pos = (
341-
self._timestamp_to_rel_index(self._buffer.time_bound_newest) + 1
341+
self._timestamp_to_rel_index(self._buffer.newest_timestamp) + 1
342342
) - dist_to_start
343343

344344
# Note that these check is working since we are using the positions
@@ -355,7 +355,7 @@ def _get_buffer_bounds(
355355

356356
# add the offset to the oldest sample in the ringbuffer and wrap around
357357
# to get the start and end positions in the ringbuffer
358-
rb_offset = self._buffer.datetime_to_index(self._buffer.time_bound_oldest)
358+
rb_offset = self._buffer.datetime_to_index(self._buffer.oldest_timestamp)
359359
start_pos = self._buffer.wrap(end_pos + self._period + rb_offset)
360360
end_pos = self._buffer.wrap(end_pos + rb_offset)
361361

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,19 @@ def update(self, sample: Sample[QuantityT]) -> None:
156156
self._update_gaps(timestamp, prev_newest, sample.value is None)
157157

158158
@property
159-
def time_bound_oldest(self) -> datetime:
159+
def oldest_timestamp(self) -> datetime:
160160
"""
161-
Return the time bounds of the ring buffer.
161+
The timestamp of the oldest sample of the ring buffer.
162162
163163
Returns:
164164
The timestamp of the oldest sample of the ring buffer.
165165
"""
166166
return self._datetime_oldest
167167

168168
@property
169-
def time_bound_newest(self) -> datetime:
169+
def newest_timestamp(self) -> datetime:
170170
"""
171-
Return the time bounds of the ring buffer.
171+
The timestamp of the newest sample of the ring buffer.
172172
173173
Returns:
174174
The timestamp of the newest sample of the ring buffer.

0 commit comments

Comments
 (0)