From b7f0403c50fb93fcf30e09a0b3b9415b4634847b Mon Sep 17 00:00:00 2001 From: Slobodan Ilic Date: Thu, 20 Sep 2018 22:57:19 +0200 Subject: [PATCH 1/3] Add integration and unit tests for MR with H&S - Add unit tests that prevent Dimension from returning H&S indices for selections dimension - Add integration tests with data from production. Ensure that cr.cube doesn't try to actually insert the H&S into MR dimension --- tests/integration/fixtures/__init__.py | 1 + .../fixtures/cubes/univ-mr-with-hs.json | 1183 +++++++++++++++++ tests/integration/test_crunch_cube.py | 12 + tests/unit/test_dimension.py | 8 + 4 files changed, 1204 insertions(+) create mode 100644 tests/integration/fixtures/cubes/univ-mr-with-hs.json diff --git a/tests/integration/fixtures/__init__.py b/tests/integration/fixtures/__init__.py index 4b713cbb5..b3ada448f 100644 --- a/tests/integration/fixtures/__init__.py +++ b/tests/integration/fixtures/__init__.py @@ -143,3 +143,4 @@ def _load(cube_file): CA_ITEMS_X_CA_CAT_X_CAT = _load('ca-items-x-ca-cat-x-cat.json') CAT_X_MR_X_CAT = _load('cat-x-mr-x-cat.json') CAT_X_CAT_FILTERED_POP = _load('cat-x-cat-filtered-population.json') +UNIV_MR_WITH_HS = _load('univ-mr-with-hs.json') diff --git a/tests/integration/fixtures/cubes/univ-mr-with-hs.json b/tests/integration/fixtures/cubes/univ-mr-with-hs.json new file mode 100644 index 000000000..28de0a2cb --- /dev/null +++ b/tests/integration/fixtures/cubes/univ-mr-with-hs.json @@ -0,0 +1,1183 @@ +{ + "dataset": { + "dataset_id": "735dd266b8ca47ee8849af70fb5e5b4e", + "description": "", + "name": "Guardian tracker W+8 Fork", + "notes": "", + "population_size": null + }, + "slides": [ + { + "cube": { + "query": { + "dimensions": [ + { + "each": 1 + }, + { + "args": [ + { + "variable": "001113" + } + ], + "function": "as_selected" + } + ], + "measures": { + "count": { + "args": [], + "function": "cube_count" + } + }, + "weight": "http://127.0.0.1:8080/datasets/735dd266b8ca47ee8849af70fb5e5b4e/variables/000001X/" + }, + "query_environment": { + "filter": [] + }, + "result": { + "counts": [ + 10587, + 22771, + 0, + 5171, + 28187, + 0, + 1930, + 31428, + 0, + 3984, + 29374, + 0, + 3070, + 30288, + 0, + 2189, + 31169, + 0, + 773, + 32585, + 0, + 14751, + 18607, + 0, + 677, + 32681, + 0 + ], + "dimensions": [ + { + "derived": true, + "references": { + "alias": "Q17", + "description": "Which, if any, of the following ways have you used to pay for news in the last year?", + "name": "Paid for news in the last year", + "notes": "All News readers", + "subreferences": [ + { + "alias": "Q17_1", + "name": "A newspaper (printed) in a shop", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_2", + "name": "A printed newspaper subscription", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_3", + "name": "A single one-off payment to access a single article or edition online", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_4", + "name": "An ongoing payment subscription for a digital news service \u2013 eg monthly, quarterly or annual payment (subscription or membership)", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_5", + "name": "Pay for digital news as part of a print-digital bundle, or I get it for free as part of a print subscription", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_6", + "name": "I have made a donation to support a digital news service", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_7", + "name": "Other", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_8", + "name": "No, I haven\u2019t paid for news in the last year", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_98", + "name": "Don\u2019t know", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + } + ], + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "class": "enum", + "elements": [ + { + "id": 1, + "missing": false, + "value": { + "derived": false, + "id": "0001", + "references": { + "alias": "Q17_1", + "name": "A newspaper (printed) in a shop", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "categories": [ + { + "id": 1, + "missing": false, + "name": "Selected", + "numeric_value": 1, + "selected": true + }, + { + "id": 0, + "missing": false, + "name": "Other", + "numeric_value": 0 + }, + { + "id": -1, + "missing": true, + "name": "No Data", + "numeric_value": null + } + ], + "class": "categorical", + "ordinal": false + } + } + }, + { + "id": 2, + "missing": false, + "value": { + "derived": false, + "id": "0002", + "references": { + "alias": "Q17_2", + "name": "A printed newspaper subscription", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "categories": [ + { + "id": 1, + "missing": false, + "name": "Selected", + "numeric_value": 1, + "selected": true + }, + { + "id": 0, + "missing": false, + "name": "Other", + "numeric_value": 0 + }, + { + "id": -1, + "missing": true, + "name": "No Data", + "numeric_value": null + } + ], + "class": "categorical", + "ordinal": false + } + } + }, + { + "id": 3, + "missing": false, + "value": { + "derived": false, + "id": "0003", + "references": { + "alias": "Q17_3", + "name": "A single one-off payment to access a single article or edition online", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "categories": [ + { + "id": 1, + "missing": false, + "name": "Selected", + "numeric_value": 1, + "selected": true + }, + { + "id": 0, + "missing": false, + "name": "Other", + "numeric_value": 0 + }, + { + "id": -1, + "missing": true, + "name": "No Data", + "numeric_value": null + } + ], + "class": "categorical", + "ordinal": false + } + } + }, + { + "id": 4, + "missing": false, + "value": { + "derived": false, + "id": "0004", + "references": { + "alias": "Q17_4", + "name": "An ongoing payment subscription for a digital news service \u2013 eg monthly, quarterly or annual payment (subscription or membership)", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "categories": [ + { + "id": 1, + "missing": false, + "name": "Selected", + "numeric_value": 1, + "selected": true + }, + { + "id": 0, + "missing": false, + "name": "Other", + "numeric_value": 0 + }, + { + "id": -1, + "missing": true, + "name": "No Data", + "numeric_value": null + } + ], + "class": "categorical", + "ordinal": false + } + } + }, + { + "id": 5, + "missing": false, + "value": { + "derived": false, + "id": "0005", + "references": { + "alias": "Q17_5", + "name": "Pay for digital news as part of a print-digital bundle, or I get it for free as part of a print subscription", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "categories": [ + { + "id": 1, + "missing": false, + "name": "Selected", + "numeric_value": 1, + "selected": true + }, + { + "id": 0, + "missing": false, + "name": "Other", + "numeric_value": 0 + }, + { + "id": -1, + "missing": true, + "name": "No Data", + "numeric_value": null + } + ], + "class": "categorical", + "ordinal": false + } + } + }, + { + "id": 6, + "missing": false, + "value": { + "derived": false, + "id": "0006", + "references": { + "alias": "Q17_6", + "name": "I have made a donation to support a digital news service", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "categories": [ + { + "id": 1, + "missing": false, + "name": "Selected", + "numeric_value": 1, + "selected": true + }, + { + "id": 0, + "missing": false, + "name": "Other", + "numeric_value": 0 + }, + { + "id": -1, + "missing": true, + "name": "No Data", + "numeric_value": null + } + ], + "class": "categorical", + "ordinal": false + } + } + }, + { + "id": 7, + "missing": false, + "value": { + "derived": false, + "id": "0007", + "references": { + "alias": "Q17_7", + "name": "Other", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "categories": [ + { + "id": 1, + "missing": false, + "name": "Selected", + "numeric_value": 1, + "selected": true + }, + { + "id": 0, + "missing": false, + "name": "Other", + "numeric_value": 0 + }, + { + "id": -1, + "missing": true, + "name": "No Data", + "numeric_value": null + } + ], + "class": "categorical", + "ordinal": false + } + } + }, + { + "id": 8, + "missing": false, + "value": { + "derived": false, + "id": "0008", + "references": { + "alias": "Q17_8", + "name": "No, I haven\u2019t paid for news in the last year", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "categories": [ + { + "id": 1, + "missing": false, + "name": "Selected", + "numeric_value": 1, + "selected": true + }, + { + "id": 0, + "missing": false, + "name": "Other", + "numeric_value": 0 + }, + { + "id": -1, + "missing": true, + "name": "No Data", + "numeric_value": null + } + ], + "class": "categorical", + "ordinal": false + } + } + }, + { + "id": 9, + "missing": false, + "value": { + "derived": false, + "id": "0009", + "references": { + "alias": "Q17_98", + "name": "Don\u2019t know", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "categories": [ + { + "id": 1, + "missing": false, + "name": "Selected", + "numeric_value": 1, + "selected": true + }, + { + "id": 0, + "missing": false, + "name": "Other", + "numeric_value": 0 + }, + { + "id": -1, + "missing": true, + "name": "No Data", + "numeric_value": null + } + ], + "class": "categorical", + "ordinal": false + } + } + } + ], + "subtype": { + "class": "variable" + } + } + }, + { + "derived": true, + "references": { + "alias": "Q17", + "description": "Which, if any, of the following ways have you used to pay for news in the last year?", + "name": "Paid for news in the last year", + "notes": "All News readers", + "subreferences": [ + { + "alias": "Q17_1", + "name": "A newspaper (printed) in a shop", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_2", + "name": "A printed newspaper subscription", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_3", + "name": "A single one-off payment to access a single article or edition online", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_4", + "name": "An ongoing payment subscription for a digital news service \u2013 eg monthly, quarterly or annual payment (subscription or membership)", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_5", + "name": "Pay for digital news as part of a print-digital bundle, or I get it for free as part of a print subscription", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_6", + "name": "I have made a donation to support a digital news service", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_7", + "name": "Other", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_8", + "name": "No, I haven\u2019t paid for news in the last year", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + { + "alias": "Q17_98", + "name": "Don\u2019t know", + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + } + ], + "view": { + "column_width": null, + "include_missing": false, + "include_noneoftheabove": false, + "show_counts": false, + "transform": { + "insertions": [ + { + "anchor": "bottom", + "args": [ + 1, + 2 + ], + "function": "subtotal", + "name": "Net Printed" + } + ] + } + } + }, + "type": { + "categories": [ + { + "id": 1, + "missing": false, + "name": "Selected", + "numeric_value": 1, + "selected": true + }, + { + "id": 0, + "missing": false, + "name": "Other", + "numeric_value": 0 + }, + { + "id": -1, + "missing": true, + "name": "No Data", + "numeric_value": null + } + ], + "class": "categorical", + "ordinal": false, + "subvariables": [ + "0001", + "0002", + "0003", + "0004", + "0005", + "0006", + "0007", + "0008", + "0009" + ] + } + } + ], + "element": "crunch:cube", + "filtered": { + "unweighted_n": 33358, + "weighted_n": 33364.078683702 + }, + "measures": { + "count": { + "data": [ + 10488.8965088969, + 22875.1821748055, + 0.0, + 5051.443927452, + 28312.6347562509, + 0.0, + 1960.495229921, + 31403.5834537819, + 0.0, + 3985.375341388, + 29378.7033423149, + 0.0, + 3073.367020631, + 30290.7116630719, + 0.0, + 2196.709452755, + 31167.3692309479, + 0.0, + 779.432275915, + 32584.6464077879, + 0.0, + 14859.5550671778, + 18504.5236165244, + 0.0, + 713.547824492, + 32650.5308592109, + 0.0 + ], + "metadata": { + "derived": true, + "references": {}, + "type": { + "class": "numeric", + "integer": false, + "missing_reasons": { + "No Data": -1 + }, + "missing_rules": {} + } + }, + "n_missing": 0 + } + }, + "missing": 0, + "n": 33358, + "unfiltered": { + "unweighted_n": 53334, + "weighted_n": 33497.39413943 + } + } + }, + "meta": { + "filters": [], + "format": { + "decimal_places": 0, + "pval_colors": false, + "show_empty": false + }, + "measures": [ + "col_percent" + ], + "name": "Paid for news in the last year ", + "page_layout": { + "columns": { + "alias": false, + "description": false, + "merge_ranges": true, + "notes": false, + "right": [] + }, + "rows": { + "alias": false, + "bottom": [], + "description": true, + "notes": false + } + }, + "subtitle": "", + "title": "Paid for news in the last year", + "viz_type": "table", + "weight": "weight" + } + } + ] +} diff --git a/tests/integration/test_crunch_cube.py b/tests/integration/test_crunch_cube.py index 320746d1e..83fcf890f 100644 --- a/tests/integration/test_crunch_cube.py +++ b/tests/integration/test_crunch_cube.py @@ -56,6 +56,7 @@ from .fixtures import GENDER_X_WEIGHT from .fixtures import CAT_X_MR_X_CAT from .fixtures import CAT_X_CAT_FILTERED_POP +from .fixtures import UNIV_MR_WITH_HS from . import assert_scale_means_equal @@ -1866,3 +1867,14 @@ def test_proportions_cat_x_mr_x_cat(self): ]) actual = compress_pruned(props[1]) np.testing.assert_almost_equal(actual, expected) + + def test_univ_mr_with_hs_does_not_crash(self): + """Assert that MR with H&S doesn't crash.""" + cube = CrunchCube(UNIV_MR_WITH_HS['slides'][0]['cube']) + cube.as_array(include_transforms_for_dims=[0]) + # If it doesn't crash, the test passes, we don't actually care about + # the result. We only care that the H&S transform doesn't crash the MR + # variable (that it doesn't try to actually include the transform + # in the result). H&S shouldn't be in the MR variable, but there + # are cases when there are. + assert True diff --git a/tests/unit/test_dimension.py b/tests/unit/test_dimension.py index 146c45d36..9d504b696 100644 --- a/tests/unit/test_dimension.py +++ b/tests/unit/test_dimension.py @@ -383,3 +383,11 @@ def test_values(self, mock_type): expected = [1, 2, np.nan] actual = dim.values self.assertEqual(actual, expected) + + @patch('cr.cube.dimension.Dimension.is_selections', True) + @patch('cr.cube.dimension.Dimension._get_type') + def test_hs_indices_for_mr(self, mock_type): + dim = Dimension({}) + expected = [] + actual = dim.hs_indices + assert actual == expected From 3af581d3d98bc6fe2d8afa10ed34317b328600d2 Mon Sep 17 00:00:00 2001 From: Slobodan Ilic Date: Fri, 21 Sep 2018 08:45:51 +0200 Subject: [PATCH 2/3] Guard against H&S in MR --- src/cr/cube/crunch_cube.py | 3 ++- src/cr/cube/dimension.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cr/cube/crunch_cube.py b/src/cr/cube/crunch_cube.py index e248739d9..ccf89dc2a 100644 --- a/src/cr/cube/crunch_cube.py +++ b/src/cr/cube/crunch_cube.py @@ -152,7 +152,8 @@ def _transform(self, res, include_transforms_for_dims, i - dim_offset in include_transforms_for_dims) if dim.type == 'multiple_response': dim_offset += 1 - if not transform or dim.type in ITEM_DIMENSION_TYPES: + if (not transform or + dim.type in ITEM_DIMENSION_TYPES or dim.is_selections): continue # Perform transformations insertions = self._insertions(res, dim, i) diff --git a/src/cr/cube/dimension.py b/src/cr/cube/dimension.py index fd0c6ada8..5e389b9b1 100644 --- a/src/cr/cube/dimension.py +++ b/src/cr/cube/dimension.py @@ -179,6 +179,9 @@ def elements_by_id(self): @lazyproperty def hs_indices(self): '''Headers and Subtotals indices.''' + if self.is_selections: + return [] + eid = self.elements_by_id indices = [] From 34db6a9cebafa51959f05d3c51a6c3c52f2b1e28 Mon Sep 17 00:00:00 2001 From: Slobodan Ilic Date: Fri, 21 Sep 2018 09:16:59 +0200 Subject: [PATCH 3/3] Bump version and update release notes --- README.md | 61 +++++++++++++++++++++++++++++++++---------------------- setup.py | 2 +- 2 files changed, 38 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 48a1cdb6e..3c8c954bc 100644 --- a/README.md +++ b/README.md @@ -96,46 +96,59 @@ The detailed description can be found ## Changes -1.0 Initial release +### 1.0 Initial release -1.1 *Fix stray ipdb. +### 1.1 Fix stray ipdb. -1.2 Support exporter +### 1.2 Support exporter -1.3 Implement Headers & Subtotals +### 1.3 Implement Headers & Subtotals -1.4 Update based on tabbook tests from `cr.lib` +### 1.4 Update based on tabbook tests from `cr.lib` -1.4.1 Update based on deck tests from `cr.server` +#### 1.4.1 Update based on deck tests from `cr.server` -1.4.2 Fix bugs discovered by first `cr.exporter` deploy to alpha +#### 1.4.2 Fix bugs discovered by first `cr.exporter` deploy to alpha -1.4.3 Fix bug (exporting 2D crtab with H&S on row only) +#### 1.4.3 Fix bug (exporting 2D crtab with H&S on row only) -1.4.4 Implement obtaining labels with category ids (useful for H&S in exporter) +#### 1.4.4 Implement obtaining labels with category ids (useful for H&S in exporter) -1.4.5 Fix MR x MR proportions calculation +#### 1.4.5 Fix MR x MR proportions calculation -1.5.0 Start implementing index table functionality +### 1.5.0 Start implementing index table functionality -1.5.1 Implement index for MR x MR +#### 1.5.1 Implement index for MR x MR -1.5.2 Fix bugs with `anchor: 0` for H&S +#### 1.5.2 Fix bugs with `anchor: 0` for H&S -1.5.3 Fix bugs with invalid input data for H&S +#### 1.5.3 Fix bugs with invalid input data for H&S -1.6.0 Z-Score and bug fixes. +### 1.6.0 Z-Score and bug fixes. -1.6.1 standardized_residuals are now included. +#### 1.6.1 `standardized_residuals` are now included. -1.6.2 support "Before" and "After" in variable transformations since they exist in zz9 data. +#### 1.6.2 support "Before" and "After" in variable transformations since they exist in zz9 data. -1.6.4 Fixes for 3d Pruning. +#### 1.6.4 Fixes for 3d Pruning. -1.6.5 Fixes for Pruning and Headers and subtotals. - Population size support. - Fx various calculations in 3d cubes. +#### 1.6.5 Fixes for Pruning and Headers and subtotals. +- Population size support. +- Fx various calculations in 3d cubes. -1.6.6 Added support for CubeSlice, which always represents a - 2D cube (even if they're the slices of a 3D cube). - Various fixes for support of wide-export +#### 1.6.6 Added support for CubeSlice, which always represents a +- 2D cube (even if they're the slices of a 3D cube). +- Various fixes for support of wide-export + +#### 1.6.7 Population fraction +- Various bugfixes and optimizations. +- Add property `population_fraction`. This is needed for the exporter to be able to calculate the correct population counts, based on weighted/unweighted and filtered/unfiltered states of the cube. +- Apply newly added `population_fraction` to the calculation of `population_counts`. +- Modify API for `scale_means`. It now accepts additional parameters `hs_dims` (defaults to `None`) and `prune` (defaults to `False`). Also, the format of the return value is slightly different in nature. It is a list of lists of numpy arrrays. It functions like this: + - The outermost list corresponds to cube slices. If cube.ndim < 3, then it's a single-element list + - Inner lists have either 1 or 2 elements (if they're a 1D cube slice, or a 2D cube slice, respectively). + - If there are scale means defined on the corresponding dimension of the cube slice, then the inner list element is a numpy array with scale means. If it doesn't have scale means defined (numeric values), then the element is `None`. +- Add property `ca_dim_ind` to `CubeSlice`. +- Add property `is_double_mr` to `CubeSlice` (which is needed since it differs from the interpretation of the cube. E.g. MR x CA x MR will render slices which are *not* double MRs). +- Add `shape`, `ndim`, and `scale_means` to `CubeSlice`, for accessibility. +- `index` now also operates on slices (no api change). diff --git a/setup.py b/setup.py index fc6f022fa..4a0ffb86e 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages -version = '1.6.6' +version = '1.6.7' def get_long_desc():