Skip to content

Commit 2312469

Browse files
[178390751]: fix rebase problems
1 parent 0687cd7 commit 2312469

File tree

6 files changed

+47
-41
lines changed

6 files changed

+47
-41
lines changed

src/cr/cube/cubepart.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,12 +1255,6 @@ def _only_larger(self):
12551255
# matrix/measures.py
12561256
return self._columns_dimension.pairwise_significance_spec.only_larger
12571257

1258-
@lazyproperty
1259-
def _row_variance(self):
1260-
"""2D np.float64 ndarray of row-percentage variance for each cell."""
1261-
p = self.row_proportions
1262-
return p * (1 - p)
1263-
12641258
@lazyproperty
12651259
def _rows_dimension(self):
12661260
return self._dimensions[0]

src/cr/cube/matrix/assembler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
)
2121
from cr.cube.enums import (
2222
COLLATION_METHOD as CM,
23-
DIMENSION_TYPE as DT,
2423
MARGINAL,
2524
MARGINAL_ORIENTATION as MO,
2625
MEASURE as M,

src/cr/cube/matrix/measure.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from cr.cube.matrix.subtotals import (
1313
SumSubtotals,
1414
NanSubtotals,
15-
NoneSubtotals,
1615
)
1716
from cr.cube.util import lazyproperty
1817

@@ -1649,8 +1648,7 @@ class _PairwiseSigPvals(_PairwiseSigTstats):
16491648
@lazyproperty
16501649
def blocks(self):
16511650
"""2D array of the four 2D "blocks" making up this measure."""
1652-
col_idx = self._selected_column_idx
1653-
t_stats = self._second_order_measures.pairwise_t_stats(col_idx).blocks
1651+
t_stats = self._t_stats_blocks
16541652
column_bases = self._second_order_measures.column_unweighted_bases.blocks
16551653
body_selected_base = self._selected_columns_base(0)
16561654
ins_selected_base = self._selected_columns_base(1)
@@ -1686,12 +1684,11 @@ def _selected_columns_base(self, table_index):
16861684
intersections). By choosing between them, we get the bases in a shape that we
16871685
don't have to broadcast.
16881686
"""
1689-
col_idx = self._selected_column_idx
16901687
column_bases = self._second_order_measures.column_unweighted_bases.blocks
16911688
return (
1692-
column_bases[table_index][1][:, [col_idx]]
1693-
if col_idx < 0
1694-
else column_bases[table_index][0][:, [col_idx]]
1689+
column_bases[table_index][1][:, [self._insertion_idx]]
1690+
if self._insertion_idx is not None
1691+
else column_bases[table_index][0][:, [self._col_idx]]
16951692
)
16961693

16971694
@lazyproperty

tests/integration/test_pairwise_significance.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,9 +1190,11 @@ def test_mean_diff_significance_for_numeric_array_grouped_by_cat(self):
11901190

11911191
def test_mean_diff_significance_for_numeric_array_grouped_by_cat_hs(self):
11921192
transforms = {
1193-
"pairwise_indices": {"alpha": [0.5]},
11941193
"columns_dimension": {
1195-
"pairwise_significance": {"column_significance": {"insertion_id": 1}},
1194+
"pairwise_significance": {
1195+
"column_significance": {"insertion_id": 1},
1196+
"pairwise_indices": {"alpha": [0.5]},
1197+
},
11961198
"insertions": [
11971199
{
11981200
"function": "subtotal",
@@ -1234,7 +1236,8 @@ def test_mean_diff_significance_for_numeric_array_grouped_by_cat_hs(self):
12341236
)
12351237

12361238
transforms["columns_dimension"]["pairwise_significance"] = {
1237-
"column_significance": {"column_idx": 4}
1239+
"column_significance": {"column_idx": 4},
1240+
"pairwise_indices": {"alpha": [0.5]},
12381241
}
12391242
slice_ = Cube(
12401243
NA.NUM_ARR_MEANS_GROUPED_BY_CAT_HS, transforms=transforms
@@ -1324,7 +1327,7 @@ def test_mean_diff_significance_for_numeric_array_x_mr(self):
13241327
def test_mean_diff_significance_indices_for_numeric_array_grouped_by_cat(self):
13251328
transforms = {
13261329
"columns_dimension": {
1327-
"pairwise_significance": {"pairwise_indices": {"alpha": [0.05, 0.08]}}
1330+
"pairwise_significance": {"pairwise_indices": {"alpha": [0.45, 0.333]}}
13281331
}
13291332
}
13301333
slice_ = Cube(
@@ -1416,13 +1419,15 @@ def test_mean_diff_significance_for_cat_x_cat(self):
14161419
slice_ = Cube(
14171420
CR.MEAN_CAT_X_CAT,
14181421
transforms={
1419-
"pairwise_indices": {"alpha": [0.1]},
14201422
"rows_dimension": {
14211423
"elements": {"1": {"hide": True}},
14221424
"prune": True,
14231425
},
14241426
"columns_dimension": {
1425-
"pairwise_significance": {"column_significance": {"column_idx": 1}},
1427+
"pairwise_significance": {
1428+
"column_significance": {"column_idx": 1},
1429+
"pairwise_indices": {"alpha": [0.1]},
1430+
},
14261431
"elements": {"1": {"hide": True}},
14271432
"prune": True,
14281433
"order": {"type": "explicit", "element_ids": [4, 2, 5, 0]},
@@ -1456,7 +1461,7 @@ def test_mean_diff_significance_for_cat_x_cat(self):
14561461
def test_mean_diff_significance_indices_for_cat_x_cat(self):
14571462
transforms = {
14581463
"columns_dimension": {
1459-
"pairwise_significance": {"pairwise_indices": {"alpha": [0.05, 0.01]}}
1464+
"pairwise_significance": {"pairwise_indices": {"alpha": [0.15, 0.05]}}
14601465
}
14611466
}
14621467
slice_ = Cube(CR.MEAN_CAT_X_CAT, transforms=transforms).partitions[0]

tests/unit/matrix/test_assembler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
_Means,
4444
_PopulationProportions,
4545
_PopulationStandardError,
46-
_MarginProportion,
4746
_PairwiseIndices,
4847
_PairwiseSubvarIndices,
4948
_PairwiseMeansIndices,

tests/unit/matrix/test_measure.py

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ def it_provides_the_df(self, request):
700700
cube_measures_ = instance_mock(request, CubeMeasures)
701701
cube_measures_.cube_stddev = cube_std_dev_
702702
cube_measures_.unweighted_cube_counts = unweighted_cube_counts_
703-
pairwise_pvals = _PairwiseMeansSigPVals(None, None, cube_measures_, 0)
703+
pairwise_pvals = _PairwiseMeansSigPVals(None, None, cube_measures_, None, 0)
704704

705705
assert pairwise_pvals._df == pytest.approx(np.array([[44, 37.8554]]))
706706

@@ -724,7 +724,7 @@ def it_provides_the_tstats(self, request):
724724
cube_measures_.cube_means = cube_means_
725725
cube_measures_.cube_stddev = cube_std_dev_
726726
cube_measures_.unweighted_cube_counts = unweighted_cube_counts_
727-
pairwise_tstat = _PairwiseMeansSigTStats(None, None, cube_measures_, 0)
727+
pairwise_tstat = _PairwiseMeansSigTStats(None, None, cube_measures_, None, 0)
728728

729729
assert pairwise_tstat.t_stats == pytest.approx(np.array([[0, 2.310889]]))
730730

@@ -737,7 +737,7 @@ def it_provides_a_blocks_interface(self, request):
737737
property_mock(request, _PairwiseSigTstats, "_subtotal_columns", return_value=2)
738738
property_mock(request, _PairwiseSigTstats, "_subtotal_rows", return_value=3)
739739
property_mock(request, _PairwiseSigTstats, "_intersections", return_value=4)
740-
pairwise_tstat = _PairwiseSigTstats(None, None, None, None)
740+
pairwise_tstat = _PairwiseSigTstats(None, None, None, None, None)
741741

742742
assert pairwise_tstat.blocks == [[1, 2], [3, 4]]
743743

@@ -748,7 +748,7 @@ def it_calculates_the_base_values_to_help(
748748
_proportions_prop_.return_value = [[0.5, 0.6], [0.7, 0.8]]
749749
_reference_values_.return_value = [9, 0]
750750
_calculate_t_stats_.return_value = "tstat"
751-
pairwise_tstat = _PairwiseSigTstats(None, None, None, None)
751+
pairwise_tstat = _PairwiseSigTstats(None, None, None, None, None)
752752

753753
base_values = pairwise_tstat._base_values
754754

@@ -758,12 +758,14 @@ def it_calculates_the_base_values_to_help(
758758

759759
def it_provides_the_bases_to_help(self, second_order_measures_):
760760
second_order_measures_.column_unweighted_bases.blocks = [1, 2]
761-
pairwise_tstat = _PairwiseSigTstats(None, second_order_measures_, None, None)
761+
pairwise_tstat = _PairwiseSigTstats(
762+
None, second_order_measures_, None, None, None
763+
)
762764

763765
assert pairwise_tstat._bases == [1, 2]
764766

765767
def it_can_calculate_the_t_stat_to_help(self):
766-
pairwise_tstat = _PairwiseSigTstats(None, None, None, None)
768+
pairwise_tstat = _PairwiseSigTstats(None, None, None, None, None)
767769

768770
actual = pairwise_tstat._calculate_t_stats(
769771
np.array([[0.5, 0.3, 0.1], [0.5, 0.7, 0.9]]),
@@ -786,7 +788,7 @@ def it_can_calculate_the_t_stat_to_help(self):
786788
)
787789

788790
def but_tstat_calculation_is_ok_with_empty_inputs(self):
789-
pairwise_tstat = _PairwiseSigTstats(None, None, None, None)
791+
pairwise_tstat = _PairwiseSigTstats(None, None, None, None, None)
790792

791793
actual = pairwise_tstat._calculate_t_stats(
792794
np.array([[]]),
@@ -804,7 +806,7 @@ def it_provides_the_intersections_to_help(
804806
_proportions_prop_.return_value = [[0.5, 0.6], [0.7, 0.8]]
805807
_reference_values_.return_value = [9, 0]
806808
_calculate_t_stats_.return_value = "tstat"
807-
pairwise_tstat = _PairwiseSigTstats(None, None, None, None)
809+
pairwise_tstat = _PairwiseSigTstats(None, None, None, None, None)
808810

809811
base_values = pairwise_tstat._intersections
810812

@@ -814,22 +816,30 @@ def it_provides_the_intersections_to_help(
814816

815817
def it_provides_the_proportions_to_help(self, second_order_measures_):
816818
second_order_measures_.column_proportions.blocks = [1, 2]
817-
pairwise_tstat = _PairwiseSigTstats(None, second_order_measures_, None, None)
819+
pairwise_tstat = _PairwiseSigTstats(
820+
None, second_order_measures_, None, None, None
821+
)
818822

819823
assert pairwise_tstat._proportions == [1, 2]
820824

821825
@pytest.mark.parametrize(
822-
"col_index, block_index, expected",
826+
"insertion_index, col_index, block_index, expected",
823827
(
824-
(0, 0, ("0", "2")),
825-
(1, 0, ("1", "3")),
826-
(1, 1, ("10", "12")),
827-
(-1, 0, ("6", "8")),
828-
(-2, 1, ("13", "15")),
828+
(None, 0, 0, ("0", "2")),
829+
(None, 1, 0, ("1", "3")),
830+
(None, 1, 1, ("10", "12")),
831+
(1, None, 0, ("6", "8")),
832+
(0, None, 1, ("13", "15")),
829833
),
830834
)
831835
def it_can_calculate_the_reference_values_to_help(
832-
self, _bases_prop_, _proportions_prop_, col_index, block_index, expected
836+
self,
837+
_bases_prop_,
838+
_proportions_prop_,
839+
insertion_index,
840+
col_index,
841+
block_index,
842+
expected,
833843
):
834844
_bases_prop_.return_value = [
835845
[
@@ -851,7 +861,9 @@ def it_can_calculate_the_reference_values_to_help(
851861
np.array([["p13", "p14"], ["p15", "p16"]]),
852862
],
853863
]
854-
pairwise_tstat = _PairwiseSigTstats(None, None, None, col_index)
864+
pairwise_tstat = _PairwiseSigTstats(
865+
None, None, None, insertion_index, col_index
866+
)
855867

856868
actual = pairwise_tstat._reference_values(block_index)
857869

@@ -865,7 +877,7 @@ def it_provides_the_subtotal_columns_to_help(
865877
_proportions_prop_.return_value = [[0.5, 0.6], [0.7, 0.8]]
866878
_reference_values_.return_value = [9, 0]
867879
_calculate_t_stats_.return_value = "tstat"
868-
pairwise_tstat = _PairwiseSigTstats(None, None, None, None)
880+
pairwise_tstat = _PairwiseSigTstats(None, None, None, None, None)
869881

870882
base_values = pairwise_tstat._subtotal_columns
871883

@@ -880,7 +892,7 @@ def it_provides_the_subtotal_rows_to_help(
880892
_proportions_prop_.return_value = [[0.5, 0.6], [0.7, 0.8]]
881893
_reference_values_.return_value = [9, 0]
882894
_calculate_t_stats_.return_value = "tstat"
883-
pairwise_tstat = _PairwiseSigTstats(None, None, None, None)
895+
pairwise_tstat = _PairwiseSigTstats(None, None, None, None, None)
884896

885897
base_values = pairwise_tstat._subtotal_rows
886898

0 commit comments

Comments
 (0)