Skip to content

Commit

Permalink
slice: add .scale_mean_pairwise_indices_alt
Browse files Browse the repository at this point in the history
  • Loading branch information
scanny committed Jun 9, 2020
1 parent a1d34a1 commit 31a96a9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/cr/cube/cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,23 @@ def scale_mean_pairwise_indices(self):
).tolist()
)

@lazyproperty
def scale_mean_pairwise_indices_alt(self):
"""Sequence of column-idx tuples indicating pairwise-t result of scale-means.
Same calculation as `.scale_mean_pairwise_indices` using the `._alpha_alt`
value. None when no secondary alpha value was specified. The length of the
sequence is that of the columns-dimension.
"""
if self._alpha_alt is None:
return None

return tuple(
PairwiseSignificance.scale_mean_pairwise_indices(
self, self._alpha_alt, self._only_larger
).tolist()
)

@lazyproperty
def scale_means_column(self):
if np.all(np.isnan(self._columns_dimension_numeric)):
Expand Down
1 change: 0 additions & 1 deletion tests/integration/test_pairwise_significance.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def it_provides_scale_mean_pairwise_indices(self, fixture, expectation):
expected = load_python_expression(expectation)
assert expected == actual, "\n%s\n\n%s" % (expected, actual)

@pytest.mark.xfail(reason="WIP", strict=True)
@pytest.mark.parametrize(
"fixture, expectation",
(
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/test_cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,31 @@ def it_knows_the_rows_margin(self, request, _matrix_prop_, matrix_):

np.testing.assert_almost_equal(rows_margin, [[1, 2], [3, 4]])

def it_provides_the_secondary_scale_mean_pairwise_indices(
self, _alpha_alt_prop_, _only_larger_prop_, PairwiseSignificance_
):
PairwiseSignificance_.scale_mean_pairwise_indices.return_value = np.array(
[(2,), (0,), ()]
)
_alpha_alt_prop_.return_value = 0.42
_only_larger_prop_.return_value = True
slice_ = _Slice(None, None, None, None, None)

scale_mean_pairwise_indices_alt = slice_.scale_mean_pairwise_indices_alt

PairwiseSignificance_.scale_mean_pairwise_indices.assert_called_once_with(
slice_, 0.42, True
)
assert scale_mean_pairwise_indices_alt == ((2,), (0,), ())

def but_scale_mean_pairwise_indices_alt_is_None_when_no_secondary_alpha_specified(
self, _alpha_alt_prop_
):
_alpha_alt_prop_.return_value = None
slice_ = _Slice(None, None, None, None, None)

assert slice_.scale_mean_pairwise_indices_alt is None

# fixture components ---------------------------------------------

@pytest.fixture
Expand Down

0 comments on commit 31a96a9

Please sign in to comment.