Skip to content

Commit

Permalink
Merge pull request #393 from Crunch-io/fix-column-bases-186925787
Browse files Browse the repository at this point in the history
[#186925787]: Fix pairwise comparison
  • Loading branch information
slobodan-ilic authored Feb 8, 2024
2 parents cfeba1a + b11e20f commit 72e864f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/cr/cube/matrix/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1545,20 +1545,22 @@ def _column_bases(self):
calculated column bases (either 'effective' or unweighted counts) for
the analysis.
"""
unweighted_blocks = self._second_order_measures.column_unweighted_bases.blocks
if self._second_order_measures.columns_squared_base.is_defined:
weighted_blocks = self._second_order_measures.column_weighted_bases.blocks
squared_blocks = self._second_order_measures.column_squared_bases.blocks
effective_blocks = [
[
unweighted_blocks[0][0] ** 2 / squared_blocks[0][0],
unweighted_blocks[0][1] ** 2 / squared_blocks[0][1],
weighted_blocks[0][0] ** 2 / squared_blocks[0][0],
weighted_blocks[0][1] ** 2 / squared_blocks[0][1],
],
[
unweighted_blocks[1][0] ** 2 / squared_blocks[1][0],
unweighted_blocks[1][1] ** 2 / squared_blocks[1][1],
weighted_blocks[1][0] ** 2 / squared_blocks[1][0],
weighted_blocks[1][1] ** 2 / squared_blocks[1][1],
],
]
return effective_blocks

unweighted_blocks = self._second_order_measures.column_unweighted_bases.blocks
return unweighted_blocks

def _reference_values(self, block_index):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -1910,8 +1910,8 @@ def it_uses_squared_weights_for_effect_calculation(self):
np.testing.assert_almost_equal(
slice_._measures.pairwise_p_vals(1).blocks[0][0],
[
[NA, 1.0, 1.0, 0.66381998, NA, NA, NA, 0.19510957, 0.66381998, NA],
[NA, 1.0, 1.0, 0.66381998, NA, NA, NA, 0.19510957, 0.66381998, NA],
[NA, 1.0, 1.0, 0.54626095, NA, NA, NA, 0.35332203, 0.54626095, NA],
[NA, 1.0, 1.0, 0.54626095, NA, NA, NA, 0.35332203, 0.54626095, NA],
],
)

Expand Down

0 comments on commit 72e864f

Please sign in to comment.