From 0f37c74b0ed2ae9fc73d926e7d2f6ef4d883ea83 Mon Sep 17 00:00:00 2001 From: Joshua Beretta Date: Wed, 7 Jul 2021 21:10:03 +0000 Subject: [PATCH 1/2] fix autoreport --- src/formpack/schema/fields.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/formpack/schema/fields.py b/src/formpack/schema/fields.py index cfa6881f..6a17dd35 100644 --- a/src/formpack/schema/fields.py +++ b/src/formpack/schema/fields.py @@ -507,8 +507,9 @@ def get_disaggregated_stats(self, metrics, top_splitters, for val, counter in metrics.items(): if val is None: continue - for splitter, count in counter.items(): - inversed_metrics[splitter].extend([val] * count) + for splitter, trans in top_splitters: + count = counter.pop(splitter, 0) + inversed_metrics[trans].extend([val] * count) for splitter, values in inversed_metrics.items(): From d5e69e3c07802ef1d1fa648b5ea3c8bcc1a66ba6 Mon Sep 17 00:00:00 2001 From: Joshua Beretta Date: Wed, 7 Jul 2021 22:03:14 +0000 Subject: [PATCH 2/2] fix breaking tests --- tests/test_autoreport.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/test_autoreport.py b/tests/test_autoreport.py index 9019a7cf..6aebf911 100644 --- a/tests/test_autoreport.py +++ b/tests/test_autoreport.py @@ -436,24 +436,24 @@ def test_disaggregate(self): 'stdev': 0.7071067811865476 } ), + ( + '2002-01-01', + { + 'mean': 2, + 'median': 2.0, + 'mode': 2, + 'stdev': 0.0 + } + ), ( '2003-01-01', { - 'mean': 1.0, + 'mean': 1, 'median': 1, 'mode': '*', 'stdev': '*' } ), - ( - '2002-01-01', - { - 'mean': 2.0, - 'median': 2.0, - 'mode': 2, - 'stdev': 0.0 - } - ) ) } )