From 8a00c17fb0581551497fcb40a8c74884b97a6429 Mon Sep 17 00:00:00 2001 From: Slobodan Ilic Date: Thu, 11 Jan 2018 15:13:51 +0100 Subject: [PATCH] Restore flattened dim in case of MR margin --- src/cr/cube/crunch_cube.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cr/cube/crunch_cube.py b/src/cr/cube/crunch_cube.py index 7b294bf82..3af5dbd4a 100644 --- a/src/cr/cube/crunch_cube.py +++ b/src/cr/cube/crunch_cube.py @@ -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)