Skip to content

Commit

Permalink
Restore flattened dim in case of MR margin
Browse files Browse the repository at this point in the history
  • Loading branch information
slobodan-ilic committed Jan 11, 2018
1 parent 5c42977 commit 8a00c17
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/cr/cube/crunch_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ def _mr_margin(self, axis, weighted, adjusted):
return np.sum(margin, 0)

if axis == 1:
if len(array.shape) == 1:
# In case of a flattened array (which happens with MR x CAT
# (single element)), restore the flattened dimension.
array = array[:, np.newaxis]

# If MR margin is calculated by rows, we only need the counts
# and that's why we use array and not margin.
return np.sum(array, axis)
Expand Down

0 comments on commit 8a00c17

Please sign in to comment.