Skip to content

Commit 0c39108

Browse files
committed
Rename MetricWithTreatment to Summary
1 parent d283552 commit 0c39108

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

pensieve/config.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535

3636
@attr.s(auto_attribs=True)
37-
class MetricWithTreatment:
37+
class Summary:
3838
"""Represents a metric with a statistical treatment."""
3939

4040
metric: mozanalysis.metrics.Metric
@@ -49,43 +49,43 @@ def run(self, data: pandas.DataFrame) -> "StatisticResultCollection":
4949
DEFAULT_METRICS = {
5050
"desktop": {
5151
AnalysisPeriod.DAY: [
52-
MetricWithTreatment(
52+
Summary(
5353
metric=mozanalysis.metrics.desktop.unenroll,
5454
treatment=BootstrapMean(num_samples=1000),
5555
)
5656
],
5757
AnalysisPeriod.WEEK: [
58-
MetricWithTreatment(
58+
Summary(
5959
metric=mozanalysis.metrics.desktop.active_hours,
6060
treatment=BootstrapMean(num_samples=1000),
6161
),
62-
MetricWithTreatment(
62+
Summary(
6363
metric=mozanalysis.metrics.desktop.uri_count,
6464
treatment=BootstrapMean(num_samples=1000),
6565
),
66-
MetricWithTreatment(
66+
Summary(
6767
metric=mozanalysis.metrics.desktop.ad_clicks,
6868
treatment=BootstrapMean(num_samples=1000),
6969
),
70-
MetricWithTreatment(
70+
Summary(
7171
metric=mozanalysis.metrics.desktop.search_count,
7272
treatment=BootstrapMean(num_samples=1000),
7373
),
7474
],
7575
AnalysisPeriod.OVERALL: [
76-
MetricWithTreatment(
76+
Summary(
7777
metric=mozanalysis.metrics.desktop.active_hours,
7878
treatment=BootstrapMean(num_samples=1000),
7979
),
80-
MetricWithTreatment(
80+
Summary(
8181
metric=mozanalysis.metrics.desktop.uri_count,
8282
treatment=BootstrapMean(num_samples=1000),
8383
),
84-
MetricWithTreatment(
84+
Summary(
8585
metric=mozanalysis.metrics.desktop.ad_clicks,
8686
treatment=BootstrapMean(num_samples=1000),
8787
),
88-
MetricWithTreatment(
88+
Summary(
8989
metric=mozanalysis.metrics.desktop.search_count,
9090
treatment=BootstrapMean(num_samples=1000),
9191
),
@@ -96,14 +96,14 @@ def run(self, data: pandas.DataFrame) -> "StatisticResultCollection":
9696
# metrics that are available in mozanalysis with a default statistical treatment
9797
AVAILABLE_METRICS = {
9898
"desktop": [
99-
MetricWithTreatment(
99+
Summary(
100100
metric=mozanalysis.metrics.desktop.view_about_logins,
101101
treatment=BootstrapMean(num_samples=1000),
102102
),
103-
MetricWithTreatment(
103+
Summary(
104104
metric=mozanalysis.metrics.desktop.unenroll, treatment=BootstrapMean(num_samples=1000),
105105
),
106-
MetricWithTreatment(
106+
Summary(
107107
metric=mozanalysis.metrics.desktop.active_hours,
108108
treatment=BootstrapMean(num_samples=1000),
109109
), # todo: add more metrics
@@ -152,7 +152,7 @@ def _lookup_name(
152152
class MetricReference:
153153
name: str
154154

155-
def resolve(self, spec: "AnalysisSpec") -> List[MetricWithTreatment]:
155+
def resolve(self, spec: "AnalysisSpec") -> List[Summary]:
156156
metrics = []
157157

158158
if self.name in spec.metrics.definitions:
@@ -230,7 +230,7 @@ class MetricDefinition:
230230
data_source: DataSourceReference
231231
statistics: Dict[str, Dict[str, Any]]
232232

233-
def resolve(self, spec: "AnalysisSpec") -> List[MetricWithTreatment]:
233+
def resolve(self, spec: "AnalysisSpec") -> List[Summary]:
234234
select_expression = _metrics_environment.from_string(self.select_expression).render()
235235

236236
metric = mozanalysis.metrics.Metric(
@@ -245,15 +245,15 @@ def resolve(self, spec: "AnalysisSpec") -> List[MetricWithTreatment]:
245245
for statistic in Statistic.__subclasses__():
246246
if statistic.name() == statistic_name:
247247
metrics_with_treatments.append(
248-
MetricWithTreatment(metric, statistic.from_dict(params))
248+
Summary(metric, statistic.from_dict(params))
249249
)
250250
else:
251251
raise ValueError(f"Statistic {statistic_name} does not exist.")
252252

253253
return metrics_with_treatments
254254

255255

256-
MetricsConfigurationType = Dict[AnalysisPeriod, List[MetricWithTreatment]]
256+
MetricsConfigurationType = Dict[AnalysisPeriod, List[Summary]]
257257

258258

259259
@attr.s(auto_attribs=True)
@@ -284,8 +284,8 @@ def from_dict(cls, d: dict) -> "MetricsSpec":
284284

285285
@staticmethod
286286
def _merge_metrics(
287-
user: Iterable[MetricWithTreatment], default: Iterable[MetricWithTreatment]
288-
) -> List[MetricWithTreatment]:
287+
user: Iterable[Summary], default: Iterable[Summary]
288+
) -> List[Summary]:
289289
result = []
290290
user_names = set()
291291

pensieve/tests/integration/test_analysis_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
from pensieve import AnalysisPeriod
1616
from pensieve.analysis import Analysis
17-
from pensieve.config import AnalysisSpec, MetricWithTreatment
17+
from pensieve.config import AnalysisSpec, Summary
1818
from pensieve.experimenter import Experiment, Variant
1919
from pensieve.statistics import BootstrapMean
2020

@@ -117,7 +117,7 @@ def build_query_test_project(instance, *args, **kwargs):
117117

118118
config.metrics = {
119119
AnalysisPeriod.WEEK: [
120-
MetricWithTreatment(test_active_hours, BootstrapMean(ref_branch_label="branch1"))
120+
Summary(test_active_hours, BootstrapMean(ref_branch_label="branch1"))
121121
]
122122
}
123123

0 commit comments

Comments
 (0)