diff --git a/src/cr/cube/measures/index.py b/src/cr/cube/measures/index.py index 47e9194e4..b479f2568 100644 --- a/src/cr/cube/measures/index.py +++ b/src/cr/cube/measures/index.py @@ -34,6 +34,7 @@ def data(self): '''Return table index by margin.''' if self.cube.has_mr: return self._mr_index() + # this margin should be calculated from the univariate cube of the row variable. margin = ( self.cube.margin(axis=0, weighted=self.weighted, prune=self.prune) / self.cube.margin(weighted=self.weighted, prune=self.prune) diff --git a/tests/integration/test_index.py b/tests/integration/test_index.py index 5dea8190e..b2a829315 100644 --- a/tests/integration/test_index.py +++ b/tests/integration/test_index.py @@ -13,12 +13,12 @@ class TestIndex(TestCase): def test_mr_x_cat_index(self): cube = CrunchCube(SELECTED_CROSSTAB_4) expected = np.array([ - [0.95865152585539, 1.0385904443566], - [1.02305106635277, 0.9784320457270], - [0.97603114632311, 1.0224274029149], - [0.98102944430498, 1.0182906820384], - [1.14466510106092, 0.8606566846476], - [0.99292572005336, 1.0068293374540] + [0.958651525855387,1.03859044435659], + [1.02305106635277,0.978432045727022], + [0.976031146323114,1.0224274029149], + [0.981029444304978,1.01829068203842], + [1.14466510106092,0.860656684647625], + [0.992925720053358,1.00682933745397] ]) actual = cube.index() np.testing.assert_almost_equal(actual, expected) @@ -26,8 +26,8 @@ def test_mr_x_cat_index(self): def test_cat_x_mr_index(self): cube = CrunchCube(CAT_X_MR_SIMPLE) expected = np.array([ - [0.8571429, 1.1152941, 0.9610984], - [1.0769231, 0.9466231, 1.019037], + [0.909090909090909,1.06951871657754,0.956937799043062], + [1.04477611940298,0.9657594381036,1.02120974076984] ]) actual = cube.index() np.testing.assert_almost_equal(actual, expected) @@ -35,9 +35,9 @@ def test_cat_x_mr_index(self): def test_mr_x_mr_index(self): cube = CrunchCube(PETS_X_PETS) expected = np.array([ - [1.0000000000000000, 1.1724137931034484, 0.894736842105263], - [0.8529411764705883, 1.0000000000000000, 0.763157894736842], - [1.1176470588235294, 1.310344827586207, 1.0000000000000000] + [2,0.96551724137931,0.947368421052632], + [0.956747404844291,2.32352941176471,0.978328173374613], + [0.975232198142415,1.01633393829401,1.84210526315789] ]) actual = cube.index() np.testing.assert_almost_equal(actual, expected)