Skip to content

Commit 39f789c

Browse files
committed
Improve resampling actor documentation
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent adf4301 commit 39f789c

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/frequenz/sdk/actor/_resampling.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# License: MIT
22
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
33

4-
"""ComponentMetricsResamplingActor used to subscribe for resampled component metrics."""
4+
"""An actor to resample microgrid component metrics."""
55

66
import asyncio
77
import dataclasses
@@ -23,16 +23,15 @@
2323

2424
# pylint: disable=unused-argument
2525
def average(samples: Sequence[Sample], resampling_period_s: float) -> float:
26-
"""Calculate average of the provided values.
26+
"""Calculate average of all the provided values.
2727
2828
Args:
29-
samples: sequences of samples to apply the average to. It must be
30-
non-empty.
31-
resampling_period_s: value describing how often resampling should be
32-
performed, in seconds
29+
samples: The samples to apply the average to. It must be non-empty.
30+
resampling_period_s: The time it passes between resampled data is
31+
produced (in seconds).
3332
3433
Returns:
35-
average of all the sample values
34+
The average of all `samples` values.
3635
"""
3736
assert len(samples) > 0, "Average cannot be given an empty list of samples"
3837
values = list(sample.value for sample in samples if sample.value is not None)
@@ -41,7 +40,7 @@ def average(samples: Sequence[Sample], resampling_period_s: float) -> float:
4140

4241
@actor
4342
class ComponentMetricsResamplingActor:
44-
"""ComponentMetricsResamplingActor used to ingest component data and resample it."""
43+
"""An actor to resample microgrid component metrics."""
4544

4645
def __init__( # pylint: disable=too-many-arguments
4746
self,
@@ -53,7 +52,7 @@ def __init__( # pylint: disable=too-many-arguments
5352
max_data_age_in_periods: float = 3.0,
5453
resampling_function: ResamplingFunction = average,
5554
) -> None:
56-
"""Initialize the ComponentMetricsResamplingActor.
55+
"""Initialize an instance.
5756
5857
Args:
5958
channel_registry: The channel registry used to get senders and
@@ -89,10 +88,10 @@ def __init__( # pylint: disable=too-many-arguments
8988
)
9089

9190
async def _subscribe(self, request: ComponentMetricRequest) -> None:
92-
"""Subscribe for data for a specific time series.
91+
"""Request data for a component metric.
9392
9493
Args:
95-
request: subscription request for a specific component metric
94+
request: The request for component metric data.
9695
"""
9796
data_source_request = dataclasses.replace(
9897
request, namespace=request.namespace + ":Source"

0 commit comments

Comments
 (0)