Skip to content

Commit 985e071

Browse files
committed
Expose count_valid in moving window
Signed-off-by: cwasicki <[email protected]>
1 parent cbec679 commit 985e071

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/frequenz/sdk/timeseries/_moving_window.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,23 @@ async def sink_buffer(sample: Sample[Quantity]) -> None:
306306
asyncio.create_task(self._resampler.resample(), name="resample")
307307
)
308308

309+
def count_valid(self) -> int:
310+
"""
311+
Count the number of valid samples in this `MovingWindow`.
312+
313+
Returns:
314+
The number of valid samples in this `MovingWindow`.
315+
"""
316+
return self._buffer.count_valid()
317+
309318
def __len__(self) -> int:
310319
"""
311320
Return the size of the `MovingWindow`s underlying buffer.
312321
313322
Returns:
314323
The size of the `MovingWindow`.
315324
"""
316-
return self._buffer.count_valid()
325+
return self.count_valid()
317326

318327
@overload
319328
def __getitem__(self, key: SupportsIndex) -> float:

0 commit comments

Comments
 (0)