Skip to content

Commit

Permalink
[178390751]: fix after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestoarbitrio committed Oct 8, 2021
1 parent f9a67d7 commit ea06064
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 105 deletions.
1 change: 1 addition & 0 deletions src/cr/cube/matrix/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,7 @@ def rows_scale_median(self):
"""Optional 1D Row scale median marginal for this cube-result"""
return self._assemble_marginal(self._measures.rows_scale_median)

@lazyproperty
def scale_mean_pairwise_indices(self):
"""1D ndarray of tuple of int pairwise-t threshold for scale means."""
marginal = self._measures.scale_mean_pairwise_indices
Expand Down
1 change: 1 addition & 0 deletions src/cr/cube/matrix/measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ def rows_weighted_base(self):
"""
return _MarginWeightedBase(self._dimensions, self, self._cube_measures, MO.ROWS)

@lazyproperty
def scale_mean_pairwise_indices(self):
"""_ScaleMeanPairwiseIndices measure object for this cube-result"""
return _ScaleMeanPairwiseIndices(
Expand Down
Empty file.
105 changes: 0 additions & 105 deletions tests/unit/test_cubepart.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,111 +60,6 @@ def it_knows_the_index_of_its_cube_in_the_cube_set(self, cube_):

assert cube_index == 42

def it_knows_the_primary_alpha_value_to_help(self, _alpha_values_prop_):
"""alpha is the primary confidence-interval threshold specified by the user."""
_alpha_values_prop_.return_value = (0.042, 0.084)
assert CubePartition(None)._alpha == 0.042

@pytest.mark.parametrize(
"alpha_values, expected_value", (((0.042, 0.084), 0.084), ((0.042, None), None))
)
def it_knows_the_secondary_alpha_value_to_help(
self, _alpha_values_prop_, alpha_values, expected_value
):
_alpha_values_prop_.return_value = alpha_values
assert CubePartition(None)._alpha_alt == expected_value

@pytest.mark.parametrize(
"pw_indices_dict, expected_value",
(
# --- default value is .05 ---
({}, (0.05, None)),
({"alpha": {}}, (0.05, None)),
({"alpha": []}, (0.05, None)),
# --- scalar (float) value sets alpha and sets alpha_alt to None ---
({"alpha": 0.025}, (0.025, None)),
# --- single (float) value sets alpha and sets alpha_alt to None ---
({"alpha": [0.03]}, (0.03, None)),
# --- two values sets alpha to lesser and alpha_alt to greater ---
({"alpha": [0.07, 0.03]}, (0.03, 0.07)),
# --- third and later values are ignored ---
({"alpha": (0.07, 0.03, "foobar")}, (0.03, 0.07)),
),
)
def it_interprets_the_provided_alpha_values_to_help(
self, pw_indices_dict, expected_value
):
cube_partition = CubePartition(None, {"pairwise_indices": pw_indices_dict})

alpha_values = cube_partition._alpha_values

assert alpha_values == expected_value

@pytest.mark.parametrize(
"pw_indices_dict, exception_type, expected_message",
(
# --- type errors ---
(
{"alpha": {"al": "pha"}},
TypeError,
"transforms.pairwise_indices.alpha, when defined, must be a list of 1 "
"or 2 float values between 0.0 and 1.0 exclusive. Got %s"
% repr({"al": "pha"}),
),
(
{"alpha": "0.05"},
TypeError,
"transforms.pairwise_indices.alpha, when defined, must be a list of 1 "
"or 2 float values between 0.0 and 1.0 exclusive. Got %s"
% repr("0.05"),
),
# --- scalar out-of-range errors ---
(
{"alpha": -0.1},
ValueError,
"alpha value, when provided, must be between 0.0 and 1.0 exclusive. "
"Got %s" % repr(-0.1),
),
(
{"alpha": 1.0},
ValueError,
"alpha value, when provided, must be between 0.0 and 1.0 exclusive. "
"Got %s" % repr(1.0),
),
# --- sequence value errors ---
(
{"alpha": [0.01, ".05"]},
ValueError,
"transforms.pairwise_indices.alpha must be a list of 1 or 2 float "
"values between 0.0 and 1.0 exclusive. Got %s" % repr([0.01, ".05"]),
),
),
)
def but_it_raises_on_invalid_alpha_values(
self, pw_indices_dict, exception_type, expected_message
):
cube_partition = CubePartition(None, {"pairwise_indices": pw_indices_dict})

with pytest.raises(exception_type) as e:
cube_partition._alpha_values

assert str(e.value) == expected_message

@pytest.mark.parametrize(
"pw_indices_dict, expected_value",
(
# --- default value is True ---
({}, True),
({"only_larger": "foobar"}, True),
({"only_larger": False}, False),
),
)
def it_knows_the_only_larger_flag_state_to_help(
self, _transforms_dict_prop_, pw_indices_dict, expected_value
):
_transforms_dict_prop_.return_value = {"pairwise_indices": pw_indices_dict}
assert CubePartition(None)._only_larger == expected_value

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

@pytest.fixture
Expand Down

0 comments on commit ea06064

Please sign in to comment.