Skip to content

Commit 5821901

Browse files
committed
Document ResamplingFunction
There is some redundancy when specifying the types for arguments and the return value because we are going to use mkdocstrings and it doesn't support this very specific use case of documenting a callable type specifically. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 00485f7 commit 5821901

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/frequenz/sdk/timeseries/resampler.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,27 @@
1919

2020

2121
ResamplingFunction = Callable[[Sequence[Sample], float], float]
22+
"""Resampling function type.
23+
24+
A resampling function produces a new sample based on a list of pre-existing
25+
samples. It can do "upsampling" when there data rate of the `input_samples`
26+
period is smaller than the `resampling_period_s`, or "downsampling" if it is
27+
bigger.
28+
29+
In general a resampling window is the same as the `resampling_period_s`, and
30+
this function might receive input samples from multiple windows in the past to
31+
enable extrapolation, but no samples from the future (so the timestamp of the
32+
new sample that is going to be produced will always be bigger than the biggest
33+
timestamp in the input data).
34+
35+
Args:
36+
input_samples (Sequence[Sample]): the sequence of pre-existing samples.
37+
resampling_period_s (float): the period in seconds (i.e. how ofter a new sample is
38+
produced.
39+
40+
Returns:
41+
new_sample (float): The value of new sample produced after the resampling.
42+
"""
2243

2344

2445
class ComponentMetricResampler:

0 commit comments

Comments
 (0)