Skip to content

Commit de5c2b7

Browse files
committed
RingBuffer: Rename variables and add comments for more clarity
Signed-off-by: Mathias L. Baumann <[email protected]>
1 parent add3ff5 commit de5c2b7

File tree

1 file changed

+9
-9
lines changed
  • src/frequenz/sdk/timeseries/_ringbuffer

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,39 +281,39 @@ def is_missing(self, timestamp: datetime) -> bool:
281281
return any(map(lambda gap: gap.contains(timestamp), self._gaps))
282282

283283
def _update_gaps(
284-
self, timestamp: datetime, newest: datetime, new_missing: bool
284+
self, timestamp: datetime, newest: datetime, record_as_missing: bool
285285
) -> None:
286286
"""Update gap list with new timestamp.
287287
288288
Args:
289289
timestamp: Timestamp of the new value.
290290
newest: Timestamp of the newest value before the current update.
291-
new_missing: if true, the given timestamp will be recorded as missing.
292-
291+
record_as_missing: if `True`, the given timestamp will be recorded as missing.
293292
"""
294-
currently_missing = self.is_missing(timestamp)
293+
found_in_gaps = self.is_missing(timestamp)
295294

296-
if not new_missing:
295+
if not record_as_missing:
297296
# Replace all gaps with one if we went far into then future
298297
if self._datetime_newest - newest >= self._full_time_range:
299298
self._gaps = [
300299
Gap(start=self._datetime_oldest, end=self._datetime_newest)
301300
]
302301
return
303302

304-
if not currently_missing and timestamp > newest + self._sampling_period:
303+
# Check if we created a gap with the addition of the new value
304+
if not found_in_gaps and timestamp > newest + self._sampling_period:
305305
self._gaps.append(
306306
Gap(start=newest + self._sampling_period, end=timestamp)
307307
)
308308

309309
# New missing entry that is not already in a gap?
310-
if new_missing:
311-
if not currently_missing:
310+
if record_as_missing:
311+
if not found_in_gaps:
312312
self._gaps.append(
313313
Gap(start=timestamp, end=timestamp + self._sampling_period)
314314
)
315315
elif len(self._gaps) > 0:
316-
if currently_missing:
316+
if found_in_gaps:
317317
self._remove_gap(timestamp)
318318

319319
self._cleanup_gaps()

0 commit comments

Comments
 (0)