File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
src/frequenz/sdk/timeseries Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -315,6 +315,16 @@ def count_valid(self) -> int:
315315 """
316316 return self ._buffer .count_valid ()
317317
318+ @property
319+ def count_covered (self ) -> int :
320+ """Count the number of samples that are covered by the oldest and newest valid samples.
321+
322+ Returns:
323+ The count of samples between the oldest and newest (inclusive) valid samples
324+ or 0 if there are is no time range covered.
325+ """
326+ return self ._buffer .count_covered
327+
318328 @overload
319329 def __getitem__ (self , key : SupportsIndex ) -> float :
320330 """See the main __getitem__ method.
Original file line number Diff line number Diff line change @@ -144,12 +144,15 @@ async def test_window_size() -> None:
144144 async with window :
145145 assert window .capacity == 5 , "Wrong window capacity"
146146 assert window .count_valid () == 0 , "Window should be empty"
147+ assert window .count_covered == 0 , "Window should be empty"
147148 await push_logical_meter_data (sender , range (0 , 2 ))
148149 assert window .capacity == 5 , "Wrong window capacity"
149150 assert window .count_valid () == 2 , "Window should be partially full"
151+ assert window .count_covered == 2 , "Window should be partially full"
150152 await push_logical_meter_data (sender , range (2 , 20 ))
151153 assert window .capacity == 5 , "Wrong window capacity"
152154 assert window .count_valid () == 5 , "Window should be full"
155+ assert window .count_covered == 5 , "Window should be full"
153156
154157
155158# pylint: disable=redefined-outer-name
You can’t perform that action at this time.
0 commit comments