Skip to content

Commit

Permalink
Merge branch 'fix-ca-as-0th-scale-means-160893661' into rel-5.2.380
Browse files Browse the repository at this point in the history
  • Loading branch information
Crunch.io Jenkins Account committed Oct 1, 2018
2 parents 8baad05 + 01a9229 commit 0768a11
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from setuptools import setup, find_packages

version = '1.6.8'
version = '1.6.9'


def get_long_desc():
Expand Down
2 changes: 2 additions & 0 deletions src/cr/cube/cube_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_cube_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit 0768a11

Please sign in to comment.