File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed
Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ class MEASURE(enum.Enum):
121121 COLUMN_STDDEV = "col_std_dev"
122122 COLUMN_STDERR = "col_std_err"
123123 MEAN = "mean"
124+ MEDIAN = "median"
124125 PAIRWISE_T_TEST = "pairwise_t_test"
125126 POPULATION = "population"
126127 POPULATION_MOE = "population_moe"
@@ -170,6 +171,7 @@ class CUBE_MEASURE(enum.Enum):
170171NUMERIC_CUBE_MEASURES = frozenset (
171172 (
172173 CUBE_MEASURE .MEAN ,
174+ CUBE_MEASURE .MEDIAN ,
173175 CUBE_MEASURE .SUM ,
174176 CUBE_MEASURE .STDDEV ,
175177 CUBE_MEASURE .UNWEIGHTED_VALID_COUNT ,
@@ -180,6 +182,7 @@ class CUBE_MEASURE(enum.Enum):
180182NUMERIC_MEASURES = frozenset (
181183 (
182184 MEASURE .MEAN ,
185+ MEASURE .MEDIAN ,
183186 MEASURE .SUM ,
184187 MEASURE .STDDEV ,
185188 MEASURE .WEIGHTED_VALID_COUNT ,
Original file line number Diff line number Diff line change 11# encoding: utf-8
22
3- """Unit test suite for cr.cube.cube_slice module."""
3+ """Unit test suite for cr.cube.enums module."""
44
5- from cr .cube .enums import _DimensionType
5+ from cr .cube .enums import (
6+ CUBE_MEASURE ,
7+ MEASURE ,
8+ NUMERIC_CUBE_MEASURES ,
9+ NUMERIC_MEASURES ,
10+ _DimensionType ,
11+ )
612
713
814class Describe_DimensionType :
@@ -20,3 +26,31 @@ def it_knows_its_name(self):
2026 dimension_type = _DimensionType ("WORM_HOLE" )
2127 name = dimension_type .name
2228 assert name == "WORM_HOLE"
29+
30+
31+ class TestCubeMeasures :
32+ def test_numeric_cube_measures_intersection (self ):
33+ intersection = NUMERIC_CUBE_MEASURES & {m for m in CUBE_MEASURE }
34+ expected_intersection = {
35+ MEASURE .MEAN ,
36+ MEASURE .MEDIAN ,
37+ MEASURE .SUM ,
38+ MEASURE .STDDEV ,
39+ MEASURE .UNWEIGHTED_VALID_COUNT ,
40+ MEASURE .WEIGHTED_VALID_COUNT ,
41+ }
42+ assert sorted (list ([m .value for m in intersection ])) == sorted (
43+ list ([m .value for m in expected_intersection ])
44+ )
45+
46+ def test_numeric_cube_measures_difference (self ):
47+ difference = {m .value for m in NUMERIC_MEASURES } - {
48+ m .value for m in NUMERIC_CUBE_MEASURES
49+ }
50+ expected_difference = {
51+ "smoothed_mean" ,
52+ "total_share_sum" ,
53+ "row_share_sum" ,
54+ "col_share_sum" ,
55+ }
56+ assert list (sorted (difference )) == list (sorted (expected_difference ))
You can’t perform that action at this time.
0 commit comments