diff --git a/README.md b/README.md index ecd08e13e..45610294b 100644 --- a/README.md +++ b/README.md @@ -155,3 +155,6 @@ The detailed description can be found #### 1.6.8 Scale Means Marginal - Add capability to calculate the scale means marginal. This is used when analysing a 2D cube, and obtaining a sort of a "scale mean _total_" for each of the variables constituting a cube. + +#### 1.6.9 Bugfix +- When Categorical Array variable is selected in multitable export, and Scale Means is selected, the cube fails, because it tries to access the non-existing slice (the CA is only _interpreted_ as multiple slices in tabbooks). This fix makes sure that the export cube doesn't fail in such case. diff --git a/setup.py b/setup.py index 670a2a36e..0b641b59d 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup, find_packages -version = '1.6.8' +version = '1.6.9' def get_long_desc(): diff --git a/src/cr/cube/cube_slice.py b/src/cr/cube/cube_slice.py index dc6b48f8e..c06016c06 100644 --- a/src/cr/cube/cube_slice.py +++ b/src/cr/cube/cube_slice.py @@ -252,6 +252,8 @@ def is_double_mr(self): return self.dim_types == ['multiple_response'] * 2 def scale_means(self, hs_dims=None, prune=False): + if self.ca_as_0th: + return [None, None] return self._cube.scale_means(hs_dims, prune)[self._index] @lazyproperty diff --git a/tests/unit/test_cube_slice.py b/tests/unit/test_cube_slice.py index 5020fb775..f07df6937 100644 --- a/tests/unit/test_cube_slice.py +++ b/tests/unit/test_cube_slice.py @@ -385,3 +385,10 @@ def test_scale_means_marginal(self, mock_sm_init, mock_sm_margin): fake_axis = Mock() cs.scale_means_margin(fake_axis) assert mock_sm_margin.called_once_with(fake_axis) + + def test_scale_means_for_ca_as_0th(self): + """Test that CA as 0th slice always returns empty scale means.""" + cube = Mock() + cube.dim_types = ['categorical_array'] + cs = CubeSlice(cube, 0, ca_as_0th=True) + assert cs.scale_means() == [None, None]