34
34
35
35
36
36
@attr .s (auto_attribs = True )
37
- class MetricWithTreatment :
37
+ class Summary :
38
38
"""Represents a metric with a statistical treatment."""
39
39
40
40
metric : mozanalysis .metrics .Metric
@@ -49,43 +49,43 @@ def run(self, data: pandas.DataFrame) -> "StatisticResultCollection":
49
49
DEFAULT_METRICS = {
50
50
"desktop" : {
51
51
AnalysisPeriod .DAY : [
52
- MetricWithTreatment (
52
+ Summary (
53
53
metric = mozanalysis .metrics .desktop .unenroll ,
54
54
treatment = BootstrapMean (num_samples = 1000 ),
55
55
)
56
56
],
57
57
AnalysisPeriod .WEEK : [
58
- MetricWithTreatment (
58
+ Summary (
59
59
metric = mozanalysis .metrics .desktop .active_hours ,
60
60
treatment = BootstrapMean (num_samples = 1000 ),
61
61
),
62
- MetricWithTreatment (
62
+ Summary (
63
63
metric = mozanalysis .metrics .desktop .uri_count ,
64
64
treatment = BootstrapMean (num_samples = 1000 ),
65
65
),
66
- MetricWithTreatment (
66
+ Summary (
67
67
metric = mozanalysis .metrics .desktop .ad_clicks ,
68
68
treatment = BootstrapMean (num_samples = 1000 ),
69
69
),
70
- MetricWithTreatment (
70
+ Summary (
71
71
metric = mozanalysis .metrics .desktop .search_count ,
72
72
treatment = BootstrapMean (num_samples = 1000 ),
73
73
),
74
74
],
75
75
AnalysisPeriod .OVERALL : [
76
- MetricWithTreatment (
76
+ Summary (
77
77
metric = mozanalysis .metrics .desktop .active_hours ,
78
78
treatment = BootstrapMean (num_samples = 1000 ),
79
79
),
80
- MetricWithTreatment (
80
+ Summary (
81
81
metric = mozanalysis .metrics .desktop .uri_count ,
82
82
treatment = BootstrapMean (num_samples = 1000 ),
83
83
),
84
- MetricWithTreatment (
84
+ Summary (
85
85
metric = mozanalysis .metrics .desktop .ad_clicks ,
86
86
treatment = BootstrapMean (num_samples = 1000 ),
87
87
),
88
- MetricWithTreatment (
88
+ Summary (
89
89
metric = mozanalysis .metrics .desktop .search_count ,
90
90
treatment = BootstrapMean (num_samples = 1000 ),
91
91
),
@@ -96,14 +96,14 @@ def run(self, data: pandas.DataFrame) -> "StatisticResultCollection":
96
96
# metrics that are available in mozanalysis with a default statistical treatment
97
97
AVAILABLE_METRICS = {
98
98
"desktop" : [
99
- MetricWithTreatment (
99
+ Summary (
100
100
metric = mozanalysis .metrics .desktop .view_about_logins ,
101
101
treatment = BootstrapMean (num_samples = 1000 ),
102
102
),
103
- MetricWithTreatment (
103
+ Summary (
104
104
metric = mozanalysis .metrics .desktop .unenroll , treatment = BootstrapMean (num_samples = 1000 ),
105
105
),
106
- MetricWithTreatment (
106
+ Summary (
107
107
metric = mozanalysis .metrics .desktop .active_hours ,
108
108
treatment = BootstrapMean (num_samples = 1000 ),
109
109
), # todo: add more metrics
@@ -152,7 +152,7 @@ def _lookup_name(
152
152
class MetricReference :
153
153
name : str
154
154
155
- def resolve (self , spec : "AnalysisSpec" ) -> List [MetricWithTreatment ]:
155
+ def resolve (self , spec : "AnalysisSpec" ) -> List [Summary ]:
156
156
metrics = []
157
157
158
158
if self .name in spec .metrics .definitions :
@@ -230,7 +230,7 @@ class MetricDefinition:
230
230
data_source : DataSourceReference
231
231
statistics : Dict [str , Dict [str , Any ]]
232
232
233
- def resolve (self , spec : "AnalysisSpec" ) -> List [MetricWithTreatment ]:
233
+ def resolve (self , spec : "AnalysisSpec" ) -> List [Summary ]:
234
234
select_expression = _metrics_environment .from_string (self .select_expression ).render ()
235
235
236
236
metric = mozanalysis .metrics .Metric (
@@ -245,15 +245,15 @@ def resolve(self, spec: "AnalysisSpec") -> List[MetricWithTreatment]:
245
245
for statistic in Statistic .__subclasses__ ():
246
246
if statistic .name () == statistic_name :
247
247
metrics_with_treatments .append (
248
- MetricWithTreatment (metric , statistic .from_dict (params ))
248
+ Summary (metric , statistic .from_dict (params ))
249
249
)
250
250
else :
251
251
raise ValueError (f"Statistic { statistic_name } does not exist." )
252
252
253
253
return metrics_with_treatments
254
254
255
255
256
- MetricsConfigurationType = Dict [AnalysisPeriod , List [MetricWithTreatment ]]
256
+ MetricsConfigurationType = Dict [AnalysisPeriod , List [Summary ]]
257
257
258
258
259
259
@attr .s (auto_attribs = True )
@@ -284,8 +284,8 @@ def from_dict(cls, d: dict) -> "MetricsSpec":
284
284
285
285
@staticmethod
286
286
def _merge_metrics (
287
- user : Iterable [MetricWithTreatment ], default : Iterable [MetricWithTreatment ]
288
- ) -> List [MetricWithTreatment ]:
287
+ user : Iterable [Summary ], default : Iterable [Summary ]
288
+ ) -> List [Summary ]:
289
289
result = []
290
290
user_names = set ()
291
291
0 commit comments