Skip to content

Commit

Permalink
[#157391555]: Fix MR margin calculation with H&S
Browse files Browse the repository at this point in the history
- Don't include H&S in actual margin dimension (don't affect
  calculated margin results if there are H&S)
- Support with tests
  • Loading branch information
slobodan-ilic committed May 9, 2018
1 parent d84b703 commit 337e784
Show file tree
Hide file tree
Showing 5 changed files with 1,697 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/cr/cube/crunch_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ def _mr_margin_along_non_mr_dim(self, axis, weighted,
margin=True,
include_transforms_for_dims=include_transforms_for_dims,
)
# array = self.as_array(weighted=weighted, margin=True)

if axis == 1 and len(array.shape) == 1:
# If array representation of the cube has less dimensions than
Expand Down Expand Up @@ -543,6 +542,9 @@ def _mr_margin(self, axis, weighted, adjusted, hs_dims=None, prune=False):
elif self.ndim == 1:
return self._1d_mr_margin(axis, weighted)
elif self._calculate_along_non_mr(axis):
# Only take dims not calculated across (don't include
# H&S in margin calculation)
hs_dims = hs_dims and [dim for dim in hs_dims if dim != axis]
return self._mr_margin_along_non_mr_dim(axis, weighted, hs_dims)

is_ca_row_margin = (
Expand Down
1 change: 1 addition & 0 deletions tests/integration/fixtures/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@ def _load(cube_file):
AGE_X_ACCRPIPE = _load('age-x-accrpipe.json')
CAT_X_MR_X_CAT_MISSING = _load('cat-x-mr-x-cat-missing.json')
MR_X_CA_HS = _load('mr-x-ca-with-hs.json')
CA_X_MR_WEIGHTED_HS = _load('ca-x-mr-weighted-hs.json')
Loading

0 comments on commit 337e784

Please sign in to comment.