From 0647d56df24796f2e3b3e5483a1e0f862f99152a Mon Sep 17 00:00:00 2001 From: Slobodan Ilic Date: Mon, 15 Jan 2018 12:48:15 +0100 Subject: [PATCH] Don't throw exceptions - Return np.nan instead - As per behavior of whaam --- src/cr/cube/crunch_cube.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/cr/cube/crunch_cube.py b/src/cr/cube/crunch_cube.py index 5ae01114e..84e8889e2 100644 --- a/src/cr/cube/crunch_cube.py +++ b/src/cr/cube/crunch_cube.py @@ -821,9 +821,8 @@ def _mr_index(self, axis, weighted): if self.dimensions[0].type == 'multiple_response': if axis != 0: - raise ValueError( - 'MR x CAT index table only defined for column direction' - ) + # MR x CAT index table only defined for column direction. + return np.full(self.as_array().shape, np.nan) selected = ( table[:, 0, :, 0] if self.is_double_mr else @@ -840,9 +839,9 @@ def _mr_index(self, axis, weighted): if self.dimensions[1].type == 'multiple_response': if axis == 0: - raise ValueError( - 'CAT x MR index table not defined for column direction' - ) + # CAT x MR index table not defined for column direction. + return np.full(self.as_array().shape, np.nan) + selected = table[:, :, 0] non_selected = table[:, :, 1] margin = np.sum(selected, 0) / np.sum(selected + non_selected, 0)